Search code examples
javaserializationstanford-nlptext-analysisbytestream

Embed datafile in java code


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


Solution

  • 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.