0

I have a dictionary file that is being used for word matching, the java code is to be submitted online and get executed.(for a online coding competition) How would I be able to use the dictionary data file, while my program executes online. could it be embedded in the source code as compressed byte stream? please suggest

aman
  • 1,875
  • 4
  • 18
  • 27
  • Can you not upload the program with the datafile included, e.g. in a resource folder? – jk47 Aug 30 '14 at 14:36
  • no i cant as they have provided only space to upload the java code.Main idea is to train a model on some data file(they have provided corpus data)( i used dictionary text file instead), and the model developed would be used to correct the spelling of a word(passed as test case). – aman Aug 30 '14 at 14:53
  • Sorry, so you're only allowed to upload .java source files? Or compiled .class files? – jk47 Aug 30 '14 at 14:55
  • yes i am allowed to upload .java source file only. – aman Aug 30 '14 at 14:57
  • In that case I think your options are to either host the dictionary online somewhere and get your program to pull from there, or to simply store the data as a static map/array/whatever in a separate source file. – jk47 Aug 30 '14 at 14:59

1 Answers1

1

There are multiple ways to achieve this:

  • either refer to the dictionairy file as a remote resource in your code. This means that you ll most your dictionary file on a different online location which is well known by your online application code. You can then download the dictionary file and cache the file in memory for usage

  • You can encode the dictionary file (for instance in Base64 encoding - to take care of special characters in the dictonary file) as a predefined datastructure / buffer in your code. This means however that you need to convert your dictionary file & rebuild your application each time you adapt the dictionary file.

Pointing to a different "online" location would seem to more suitable solution.

Filip
  • 857
  • 8
  • 19
  • Not sure if the program executes offline, if thats the case i wont be able to access the file at online location.( But i may wanna try this) Talking of other option the file is 3.2 MB, so might need some compression.Dont know how to acheive that.:( – aman Aug 30 '14 at 17:26
  • Thanks Filip, Luckily the dictionary i used had direct link and could be accessed from the online editor.So i can proceed. – aman Aug 30 '14 at 18:03