I have been trying to find some reference material on how to create custom models with my own entities , like if I want to recognize the name of sports from a text.How do I do it?
try {
propFile = new File(System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/propfile.prop");
properties = new Properties();
properties.load(new FileInputStream(propFile));
String to = properties.getProperty("serializeTo");
properties.setProperty("serializeTo", "ner-customModel.ser.gz");
properties.setProperty("trainFile",System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/outputTokenized.tsv");
CRFClassifier crf = new CRFClassifier(properties);
crf.train();
String s2 = "apples are apples";
System.out.println(crf.classifyToString(s2));
crf.serializeClassifier(System.getProperty("user.dir") + "/src/edu/stanford/nlp/ie/crf/ner-customModel.ser.gz");
} catch (IOException e) {
e.printStackTrace();
}
and declare the training file and other properties in the properties file. This worked for me :)