Skip to content
Permalink
0d82ff1dc4
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
73 lines (65 sloc) 1.52 KB
package kb.howtokb.taskframe.extractor;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
/**
* @author ntandon
*
*/
public class StanfordPOSTagger implements IPOSTagger {
static MaxentTagger tagger;
@Override
public String tag(String p_Sentence) {
if (tagger == null)
tagger = new MaxentTagger(MaxentTagger.DEFAULT_JAR_PATH);
if (p_Sentence == null || p_Sentence.isEmpty()) { return ""; }
return tagger.tagString(p_Sentence);
}
/*
* Original
*
@Override
public String getTag(String input) {
String retVal = null;
if (input != null) {
int index = input.lastIndexOf('_'); // /
if (index >= 0 && index < input.length()) {
retVal = input.substring(index + 1);
}
}
return retVal;
}
@Override
public String getToken(String input) {
String retVal = null;
if (input != null) {
int index = input.lastIndexOf('_'); // /
if (index >= 0 && index < input.length()) {
retVal = input.substring(0, index);
}
}
return retVal;
}
*/
@Override
public String getTag(String input) {
String retVal = null;
if (input != null) {
int firstindex = input.indexOf('_');
int index = input.indexOf(' '); // /
if (index >= 0 && index < input.length()) {
retVal = input.substring(firstindex+1, index);
}
}
return retVal;
}
@Override
public String getToken(String input) {
String retVal = null;
if (input != null) {
int index = input.indexOf('_'); // /
if (index >= 0 && index < input.length()) {
retVal = input.substring(0, index);
}
}
return retVal;
}
}