i have tagged a simple sentence and this is my code:
package tagger;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
public class myTag {
public static void main(String[] args) {
MaxentTagger tagger = new MaxentTagger("D:/tagger/english-bidirectional-distsim.tagger");
String sample = "i go to school by bus";
String tagged = tagger.tagString(sample);
System.out.println(tagged);
}
}
this is the output:
Reading POS tagger model from D:/tagger/english-bidirectional-distsim.tagger ... done [3.0 sec].
i_LS go_VB to_TO school_NN by_IN bus_NN
after editing the properties file it doesn't have any effect at all. for example i have changed the tag separator to ( * ) but in the output it still prints ( _ ).
how could i use the model config file in eclipse?
Instead of writing a java code for this, you can use the bash file which comes in the downloaded ZIP file. After extracting the postagger's ZIP file, edit the following bash file:
It should have the following line:
Add a parameter called "-tagSeparator [YourTag]" after "-model $1":
To run it (Make sure necessary permissions are given):
Voilà!
You can load Properties file and pass it to the constructor of MaxEnt, something like this:
You can also set properties in
props
object directly:NB: if you use the original properties file and it fails with exception like
then remove
arch
andtrainFile
attributes.