本文整理汇总了Java中edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType类的典型用法代码示例。如果您正苦于以下问题:Java MorphoFeatureType类的具体用法?Java MorphoFeatureType怎么用?Java MorphoFeatureType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MorphoFeatureType类属于edu.stanford.nlp.international.morph.MorphoFeatureSpecification包,在下文中一共展示了MorphoFeatureType类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setup
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
@Override
public void setup(File path, String... options) {
//Setup the Bies tag mapping
super.setup(path, new String[0]);
for(String opt : options) {
String[] optToks = opt.split(":");
if(optToks[0].equals("UniversalMap") && optToks.length == 2) {
loadUniversalMap(optToks[1]);
} else {
//Maybe it's a morphological feature
//Both of these calls will throw exceptions if the feature is illegal/invalid
MorphoFeatureType feat = MorphoFeatureType.valueOf(optToks[0]);
List<String> featVals = morphoSpec.getValues(feat);
morphoSpec.activate(feat);
}
}
}
开发者ID:amark-india,项目名称:eventspotter,代码行数:20,代码来源:UniversalPOSMapper.java
示例2: numFeatureMatches
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
public int numFeatureMatches(MorphoFeatures other) {
int nMatches = 0;
for(Map.Entry<MorphoFeatureType, String> fPair : fSpec.entrySet()) {
if(other.hasFeature(fPair.getKey()) && other.getValue(fPair.getKey()).equals(fPair.getValue()))
nMatches++;
}
return nMatches;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:10,代码来源:MorphoFeatures.java
示例3: fromTagString
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
/**
* Assumes that the tag string has been formed using a call to getTag(). As such,
* it removes the basic category from the feature string.
* <p>
* Note that this method returns a <b>new</b> MorphoFeatures object. As a result, it
* behaves like a static method, but is non-static so that subclasses can override
* this method.
*
* @param str
*/
public MorphoFeatures fromTagString(String str) {
List<String> feats = Arrays.asList(str.split("\\-"));
MorphoFeatures mFeats = new MorphoFeatures();
for(String fPair : feats) {
String[] keyValue = fPair.split(KEY_VAL_DELIM);
if(keyValue.length != 2)//Manual state split annotations
continue;
MorphoFeatureType fName = MorphoFeatureType.valueOf(keyValue[0].trim());
mFeats.addFeature(fName, keyValue[1].trim());
}
return mFeats;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:24,代码来源:MorphoFeatures.java
示例4: toString
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
/**
* values() returns the values in the order in which they are declared. Thus we will not have
* the case where two feature types can yield two strings:
* -feat1:A-feat2:B
* -feat2:B-feat1:A
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for(MorphoFeatureType feat : MorphoFeatureType.values()) {
if(fSpec.containsKey(feat)) {
sb.append(String.format("-%s%s%s",feat.toString(),KEY_VAL_DELIM,fSpec.get(feat)));
}
}
return sb.toString();
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:17,代码来源:MorphoFeatures.java
示例5: setupMorphoFeatures
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
/**
* Configures morpho-syntactic annotations for POS tags.
*
* @param activeFeats A comma-separated list of feature values with names according
* to MorphoFeatureType.
*
*/
private String setupMorphoFeatures(String activeFeats) {
String[] feats = activeFeats.split(",");
morphoSpec = tlp.morphFeatureSpec();
for(String feat : feats) {
MorphoFeatureType fType = MorphoFeatureType.valueOf(feat.trim());
morphoSpec.activate(fType);
}
return morphoSpec.toString();
}
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:17,代码来源:ArabicTreebankParserParams.java
示例6: tokenToDatums
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
/**
* Convert token to a sequence of datums and add to iobList.
*
* @param iobList
* @param tokenText
* @param tokenLabel
* @param lastToken
* @param charIndex
* @param applyRewriteRules
*/
private static void tokenToDatums(List<CoreLabel> iobList, String token, TokenType tokType,
CoreLabel tokenLabel, String lastToken, int charIndex, boolean applyRewriteRules) {
String lastLabel = ContinuationSymbol;
String firstLabel = BeginSymbol;
if (applyRewriteRules) {
// Apply Arabic-specific re-write rules
String rawToken = tokenLabel.word();
String tag = tokenLabel.tag();
MorphoFeatureSpecification featureSpec = new ArabicMorphoFeatureSpecification();
featureSpec.activate(MorphoFeatureType.NGEN);
featureSpec.activate(MorphoFeatureType.NNUM);
MorphoFeatures features = featureSpec.strToFeatures(tag);
// Rule #1 : ت --> ة
if (features.getValue(MorphoFeatureType.NGEN).equals("F")
&& features.getValue(MorphoFeatureType.NNUM).equals("SG") && rawToken.endsWith("ت-")) {
lastLabel = RewriteTahSymbol;
}
// Rule #2 : لل --> ل ال
if (lastToken.equals("ل") && rawToken.startsWith("-ل")) {
firstLabel = RewriteTareefSymbol;
}
}
int index = tokenLabel.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class);
String origToken = tokenLabel.get(CoreAnnotations.OriginalTextAnnotation.class);
// Create datums and add to iobList
String firstChar = String.valueOf(token.charAt(0));
iobList.add(createDatum(firstChar, firstLabel, charIndex++, firstChar,
String.valueOf(origToken.charAt(0)), index++,
index, tokenLabel.get(CoreAnnotations.BeforeAnnotation.class)));
final int numChars = token.length();
for (int j = 1; j < numChars; ++j) {
String thisChar = String.valueOf(token.charAt(j));
String charLabel = (j == numChars - 1) ? lastLabel : ContinuationSymbol;
iobList.add(createDatum(thisChar, charLabel, charIndex++, thisChar,
String.valueOf(origToken.charAt(j)),index++, index, ""));
}
}
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:50,代码来源:IOBUtils.java
示例7: MorphoFeatures
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
public MorphoFeatures(MorphoFeatures other) {
this();
for(Map.Entry<MorphoFeatureType, String> entry : other.fSpec.entrySet())
this.fSpec.put(entry.getKey(), entry.getValue());
this.altTag = other.altTag;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:7,代码来源:MorphoFeatures.java
示例8: addFeature
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
public void addFeature(MorphoFeatureType feat, String val) {
fSpec.put(feat, val);
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:4,代码来源:MorphoFeatures.java
示例9: hasFeature
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
public boolean hasFeature(MorphoFeatureType feat) {
return fSpec.containsKey(feat);
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:4,代码来源:MorphoFeatures.java
示例10: getValue
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
public String getValue(MorphoFeatureType feat) {
return hasFeature(feat) ? fSpec.get(feat) : "";
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:4,代码来源:MorphoFeatures.java
示例11: MorphoFeatures
import edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType; //导入依赖的package包/类
public MorphoFeatures() {
fSpec = new HashMap<MorphoFeatureType,String>();
}
开发者ID:amark-india,项目名称:eventspotter,代码行数:4,代码来源:MorphoFeatures.java
注:本文中的edu.stanford.nlp.international.morph.MorphoFeatureSpecification.MorphoFeatureType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论