Permalink
Cannot retrieve contributors at this time
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?
HowToKB/src/kb/howtokb/taskframe/extractor/StanfordPOSTagger.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
73 lines (65 sloc)
1.52 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |