如何使用 GATE 嵌入(Java 代码)获取单词的特征,如下例所示:
type=Token;
features={category=VBG, kind=word, orth=lowercase, length=7, string=lacking};
start=NodeImpl;
id=21453;
如何使用 GATE 嵌入(Java 代码)获取单词的特征,如下例所示:
type=Token;
features={category=VBG, kind=word, orth=lowercase, length=7, string=lacking};
start=NodeImpl;
id=21453;
If you use the opennlp pos tagging it should be something like this, given that "Token" is your annotation for tokens:
token.getFeatures().get("category").toString()
should give you the string corresponding to the pos tag.
Phase: Find_Features
Input: Token
Options: control = First
Rule: get_Token_features
(
{Token}
):label
-->
:label
{
AnnotationSet tokens = inputAS.get("Token");
for(Annotation t : tokens)
{
FeatureMap fm = t.getFeatures();
System.out.println(fm);
/*
If looking for specific features go for
System.out.println( t.getFeatures().get("FeatureName").toString() );
*/
System.out.println(t.getFeatures().get("category").toString());
}
}