/**
 * Class that defines the native methods to access the comScore
 * dictionary API via JNI.
 * 
 * @author dmicol
 */
public class Categories {
    /**
     * Initializes the dictionary wrapper using the terms in domain file.
     * 
     * @param iMode
     *            the operation mode (value should be 1)
     * @param szTermsInDomainFlatFileName
     *            the terms in domain file name
     * @return whether the initialization succeeded
     */
    public native boolean InitFromTermsInDomainFlatFile(int iMode,
            String szTermsInDomainFlatFileName);

    /**
     * Loads the comScore dictionary in memory.
     * 
     * @param iMode
     *            the operation mode (value should be 1)
     * @param szTermsInDomainFlatFileName
     *            the terms in domain file name
     * @param szDictionaryName
     *            the file name of the dictionary
     * @return whether the load of the dictionary succeeded
     */
    public native boolean LoadCSDictionary(int iMode,
            String szTermsInDomainFlatFileName, String szDictionaryName);

    /**
     * Applies the dictionary to the given URL, and returns the pattern ID for
     * such URL.
     * 
     * @param szURL
     *            the url to apply the dictionary to
     * @return the pattern ID of the URL
     */
    public native long ApplyDictionaryUsingUrl(String szURL);

    static {
        System.loadLibrary("Categories");
    }
}

@@ -1,12 +1,164 @@
+import java.io.BufferedReader;%0Aimport java.io.FileInputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.IOException;%0Aimport java.util.HashMap;%0A%0A
 /**%0A * Class
@@ -212,19 +212,16 @@
 comScore
-%0A *
  diction
@@ -227,16 +227,19 @@
 nary API
+%0A *
  via JNI
@@ -292,16 +292,67 @@
 ories %7B%0A
+    private final static String DELIMITER = %22%5Ct%22;%0A%0A
     /**%0A
@@ -1643,11 +1643,1932 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Loads the file which contains the category pattern mappings.%0A     * %0A     * @param fileName%0A     *            the file name that contains the mappings.%0A     * @return the map of pattern IDs to category IDs.%0A     */%0A    public HashMap%3CLong, Long%3E loadCategoryPatternMapping(String fileName)%0A            throws IOException %7B%0A        HashMap%3CLong, Long%3E categoryPatternMap = new HashMap%3CLong, Long%3E();%0A        FileInputStream fis = new FileInputStream(fileName);%0A        BufferedReader br = new BufferedReader(new InputStreamReader(fis));%0A        while (br.ready()) %7B%0A            String line = br.readLine();%0A            String%5B%5D columns = line.trim().split(DELIMITER);%0A            Long patternID = Long.parseLong(columns%5B0%5D);%0A            Long categoryID = Long.parseLong(columns%5Bcolumns.length - 1%5D);%0A            categoryPatternMap.put(patternID, categoryID);%0A        %7D%0A        br.close();%0A        fis.close();%0A        return categoryPatternMap;%0A    %7D%0A%0A    /**%0A     * Loads the file that contains the category IDs and their corresponding names.%0A     * %0A     * @param fileName%0A     *            the file name that contains the list of category IDs and names.%0A     * @return the map of category IDs to names.%0A     */%0A    public HashMap%3CLong, String%3E loadCategoryNames(String fileName)%0A            throws IOException %7B%0A        HashMap%3CLong, String%3E categoryNames = new HashMap%3CLong, String%3E();%0A        FileInputStream fis = new FileInputStream(fileName);%0A        BufferedReader br = new BufferedReader(new InputStreamReader(fis));%0A        while (br.ready()) %7B%0A            String line = br.readLine();%0A            String%5B%5D columns = line.trim().split(DELIMITER);%0A            Long categoryID = Long.parseLong(columns%5B0%5D);%0A            String categoryName = columns%5B1%5D;%0A            categoryNames.put(categoryID, categoryName);%0A        %7D%0A        br.close();%0A        fis.close();%0A        return categoryNames;%0A    %7D
 %0A%7D%0A

Add methods to handle the files that map comScore patterns to categories.