本文整理汇总了Java中net.sf.extjwnl.data.POS.getPOSForLabel方法的典型用法代码示例。如果您正苦于以下问题:Java POS.getPOSForLabel方法的具体用法?Java POS.getPOSForLabel怎么用?Java POS.getPOSForLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.extjwnl.data.POS
的用法示例。
在下文中一共展示了POS.getPOSForLabel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRecord
import net.sf.extjwnl.data.POS; //导入方法依赖的package包/类
private void processRecord(String[] r, BiConsumer<InteractionDefinition, Collection<String>> consumer){
if (r.length < 2) {
return;
}
String type = r[0];
String subType = r[1];
if ("Type".equalsIgnoreCase(type) && "Subtype".equalsIgnoreCase(subType)) {
// Header, ignore
return;
}
String source = getOrEmpty(r, 2);
String target = getOrEmpty(r, 3);
String lemma = getOrEmpty(r, 4);
POS pos = POS.getPOSForLabel(getOrEmpty(r, 5).toLowerCase());
if (pos == null) {
// Can't include words without a POS
return;
}
InteractionDefinition i = new InteractionDefinition(type, subType, new Word(lemma, pos), source,
target);
List<String> alternatives = new ArrayList<>(r.length - 6);
for (int j = 6; j < r.length; j++) {
String alternative = r[j].trim();
if (!alternative.isEmpty()) {
alternatives.add(alternative);
}
}
consumer.accept(i, alternatives);
}
示例2: DetachSuffixesOperation
import net.sf.extjwnl.data.POS; //导入方法依赖的package包/类
public DetachSuffixesOperation(Dictionary dictionary, Map<String, Param> params) throws JWNLException {
super(dictionary, params);
suffixMap = new EnumMap<>(POS.class);
for (Param p : params.values()) {
POS pos = POS.getPOSForLabel(p.getName());
if (pos != null) {
suffixMap.put(pos, getSuffixArray(dictionary, p.getValue()));
}
}
}
示例3: baseForms
import net.sf.extjwnl.data.POS; //导入方法依赖的package包/类
public CSList<String> baseForms(String lemma, String pos) throws Exception {
CSList<String> result = null;
String lowercaseLemma = lemma.toLowerCase();
String fullpos = null;
if (pos.length() == 1)
fullpos = LangUtils.shortPOSToFullPOS(pos);
else
fullpos = pos;
String key = lowercaseLemma + "/" + fullpos;
result = bfDict.get(key);
if (result == null)
{
StringVector vector = BaseformOverrides.getWords().get(lowercaseLemma + '/' + pos);
if (vector!=null)
{
result = new CSList<String>(new String[]{ vector.get("baseform") });
}
else
{
if (supportedPartsOfSpeech.contains(fullpos))
{
// sso 7/9/2017: Verify that the lemma is an actual word and not just a random string
// before calling wnDict.getMorphologicalProcessor().lookupAllBaseForms()
String[] tokens = Util.split(lowercaseLemma);
if (tokens.length > MAX_ALLOWED_TOKENIZERS_IN_LEMMA) {
result = new CSList<String>(new String[]{ lowercaseLemma });
} else {
POS fullposobj = POS.getPOSForLabel(fullpos);
List<String> bf = (List<String>) wnDict.getMorphologicalProcessor().lookupAllBaseForms(fullposobj,lowercaseLemma);
if (bf.size() > 0)
{
String[] bfa = bf.toArray(new String [bf.size()]);
result = new CSList<String>(bfa);
}
else
result = new CSList<String>(new String[]{ lowercaseLemma });
}
}
else
{
result = new CSList<String>(new String[]{ lowercaseLemma });
}
}
bfDict.put(key, result);
}
return result;
}