本文整理汇总了Java中ixa.kaflib.Term.setLemma方法的典型用法代码示例。如果您正苦于以下问题:Java Term.setLemma方法的具体用法?Java Term.setLemma怎么用?Java Term.setLemma使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ixa.kaflib.Term
的用法示例。
在下文中一共展示了Term.setLemma方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllTagsLemmasToNAF
import ixa.kaflib.Term; //导入方法依赖的package包/类
/**
* Add all postags and lemmas to morphofeat attribute.
* @param kaf the NAF document
*/
public final void getAllTagsLemmasToNAF(final KAFDocument kaf) {
final List<List<WF>> sentences = kaf.getSentences();
for (final List<WF> wfs : sentences) {
final List<ixa.kaflib.Span<WF>> tokenSpans = new ArrayList<ixa.kaflib.Span<WF>>();
final String[] tokens = new String[wfs.size()];
for (int i = 0; i < wfs.size(); i++) {
tokens[i] = wfs.get(i).getForm();
final List<WF> wfTarget = new ArrayList<WF>();
wfTarget.add(wfs.get(i));
tokenSpans.add(KAFDocument.newWFSpan(wfTarget));
}
String[][] allPosTags = this.posTagger.getAllPosTags(tokens);
ListMultimap<String, String> morphMap = lemmatizer.getMultipleLemmas(tokens, allPosTags);
for (int i = 0; i < tokens.length; i++) {
final Term term = kaf.newTerm(tokenSpans.get(i));
List<String> posLemmaValues = morphMap.get(tokens[i]);
if (this.dictLemmatizer != null) {
dictLemmatizer.getAllPosLemmas(tokens[i], posLemmaValues);
}
String allPosLemmasSet = StringUtils.getSetStringFromList(posLemmaValues);
final String posId = Resources.getKafTagSet(allPosTags[0][i], lang);
final String type = Resources.setTermType(posId);
term.setType(type);
term.setLemma(posLemmaValues.get(0).split("#")[1]);
term.setPos(posId);
term.setMorphofeat(allPosLemmasSet);
}
}
}
示例2: DSRCToNAFNER
import ixa.kaflib.Term; //导入方法依赖的package包/类
private static void DSRCToNAFNER(KAFDocument kaf, String wordsDoc,
String markablesDoc) throws JDOMException, IOException {
// reading the words xml file
SAXBuilder sax = new SAXBuilder();
XPathFactory xFactory = XPathFactory.instance();
Document docWords = sax.build(wordsDoc);
XPathExpression<Element> expr = xFactory.compile("//word",
Filters.element());
List<Element> words = expr.evaluate(docWords);
List<WF> sentWFs = new ArrayList<>();
List<Term> sentTerms = new ArrayList<>();
// building the NAF containing the WFs and Terms
// naf sentence counter
int sentCounter = 1;
for (Element word : words) {
// sentence id and original text
String token = word.getText();
// the list contains just one list of tokens
WF wf = kaf.newWF(0, token, sentCounter);
final List<WF> wfTarget = new ArrayList<WF>();
wfTarget.add(wf);
sentWFs.add(wf);
Term term = kaf.newTerm(KAFDocument.newWFSpan(wfTarget));
term.setPos("O");
term.setLemma(token);
sentTerms.add(term);
Matcher endMatcher = endOfSentence.matcher(token);
if (endMatcher.matches()) {
sentCounter++;
}
} // end of processing words
String[] tokenIds = new String[sentWFs.size()];
for (int i = 0; i < sentWFs.size(); i++) {
tokenIds[i] = sentWFs.get(i).getId();
}
// processing markables document in mmax opinion expression files
Document markDoc = sax.build(markablesDoc);
XPathFactory markFactory = XPathFactory.instance();
XPathExpression<Element> markExpr = markFactory.compile("//ns:markable",
Filters.element(), null, Namespace.getNamespace("ns",
"www.eml.org/NameSpaces/OpinionExpression"));
List<Element> markables = markExpr.evaluate(markDoc);
for (Element markable : markables) {
if (markable.getAttributeValue("annotation_type")
.equalsIgnoreCase("target")) {
String markSpan = markable.getAttributeValue("span");
System.err.println("--> span: " + markSpan);
String removeCommaSpan = markSpan.replaceAll(",word_.*", "");
System.err.println("--> newSpan: " + removeCommaSpan);
String[] spanWords = removeCommaSpan.split("\\.\\.");
int startIndex = Integer.parseInt(spanWords[0].replace("word_", ""));
int endIndex = Integer
.parseInt(spanWords[spanWords.length - 1].replace("word_", "")) + 1;
List<String> wfIds = Arrays
.asList(Arrays.copyOfRange(tokenIds, startIndex - 1, endIndex - 1));
List<String> wfTermIds = getWFIdsFromTerms(sentTerms);
if (checkTermsRefsIntegrity(wfIds, wfTermIds)) {
List<Term> nameTerms = kaf.getTermsFromWFs(wfIds);
ixa.kaflib.Span<Term> neSpan = KAFDocument.newTermSpan(nameTerms);
List<ixa.kaflib.Span<Term>> references = new ArrayList<ixa.kaflib.Span<Term>>();
references.add(neSpan);
Entity neEntity = kaf.newEntity(references);
neEntity.setType("TARGET");
System.err.println("--> target: " + neEntity.getStr());
}
} // end of create entity
}
}