use of com.joliciel.talismane.lexicon.PosTaggerLexicon in project talismane by joliciel-informatique.
the class LexiconPosTagForStringFeature method checkInternal.
@Override
public FeatureResult<Boolean> checkInternal(TokenWrapper tokenWrapper, RuntimeEnvironment env) throws TalismaneException {
TokenWrapper innerWrapper = this.getToken(tokenWrapper, env);
if (innerWrapper == null)
return null;
FeatureResult<Boolean> result = null;
FeatureResult<String> wordToCheckResult = wordToCheckFeature.check(innerWrapper, env);
if (wordToCheckResult != null) {
FeatureResult<String> posTagResult = posTagFeature.check(innerWrapper, env);
if (posTagResult != null) {
PosTag posTag = TalismaneSession.get(sessionId).getPosTagSet().getPosTag(posTagResult.getOutcome());
String wordToCheck = wordToCheckResult.getOutcome();
PosTaggerLexicon lexicon = TalismaneSession.get(sessionId).getMergedLexicon();
Set<PosTag> posTags = lexicon.findPossiblePosTags(wordToCheck);
boolean hasPosTag = (posTags.contains(posTag));
result = this.generateResult(hasPosTag);
}
}
return result;
}
use of com.joliciel.talismane.lexicon.PosTaggerLexicon in project talismane by joliciel-informatique.
the class LexiconPosTagsForStringFeature method checkInternal.
@Override
public FeatureResult<List<WeightedOutcome<String>>> checkInternal(TokenWrapper tokenWrapper, RuntimeEnvironment env) throws TalismaneException {
TokenWrapper innerWrapper = this.getToken(tokenWrapper, env);
if (innerWrapper == null)
return null;
FeatureResult<List<WeightedOutcome<String>>> result = null;
FeatureResult<String> wordToCheckResult = wordToCheckFeature.check(innerWrapper, env);
if (wordToCheckResult != null) {
String wordToCheck = wordToCheckResult.getOutcome();
List<WeightedOutcome<String>> resultList = new ArrayList<WeightedOutcome<String>>();
PosTaggerLexicon lexicon = TalismaneSession.get(sessionId).getMergedLexicon();
Set<PosTag> posTags = lexicon.findPossiblePosTags(wordToCheck);
for (PosTag posTag : posTags) {
resultList.add(new WeightedOutcome<String>(posTag.getCode(), 1.0));
}
if (resultList.size() > 0)
result = this.generateResult(resultList);
}
return result;
}
Aggregations