本文整理汇总了Java中ixa.kaflib.Term.getWFs方法的典型用法代码示例。如果您正苦于以下问题:Java Term.getWFs方法的具体用法?Java Term.getWFs怎么用?Java Term.getWFs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ixa.kaflib.Term
的用法示例。
在下文中一共展示了Term.getWFs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterTerms
import ixa.kaflib.Term; //导入方法依赖的package包/类
public static List<Term> filterTerms(final Iterable<Term> terms) {
final List<Term> result = Lists.newArrayList();
boolean atBeginning = true;
for (final Term term : Ordering.from(Term.OFFSET_COMPARATOR).sortedCopy(terms)) {
final char pos = Character.toUpperCase(term.getPos().charAt(0));
if (atBeginning && (pos == 'D' || pos == 'P')) {
continue;
}
for (final WF word : term.getWFs()) {
final String text = word.getForm();
if (SYMBOLS.contains(text) || !WF_EXCLUSION_PATTERN.matcher(text).matches()) {
result.add(term);
atBeginning = false;
break;
}
}
}
return result;
}
示例2: endOf
import ixa.kaflib.Term; //导入方法依赖的package包/类
private static int endOf(final Term term) {
final List<WF> wfs = term.getWFs();
final WF wf = wfs.get(wfs.size() - 1);
final String str = wf.getForm();
if (str.equals("-LSB-") || str.equals("-RSB-") || str.equals("''")) {
return wf.getOffset() + 1;
}
return wf.getOffset() + wf.getLength();
}
示例3: getText
import ixa.kaflib.Term; //导入方法依赖的package包/类
public static String getText(final Iterable<Term> terms) {
final StringBuilder builder = new StringBuilder();
boolean atBeginning = true;
for (final Term term : Ordering.from(Term.OFFSET_COMPARATOR).sortedCopy(terms)) {
final boolean properNoun = term.getMorphofeat().startsWith("NNP");
for (final WF word : term.getWFs()) {
builder.append(atBeginning ? "" : " ");
builder.append(properNoun ? word.getForm() : word.getForm().toLowerCase());
atBeginning = false;
}
}
return builder.toString();
}
示例4: getEnd
import ixa.kaflib.Term; //导入方法依赖的package包/类
public static int getEnd(final Term term) {
final List<WF> wfs = term.getWFs();
final WF wf = wfs.get(wfs.size() - 1);
final String str = wf.getForm();
if (str.equals("-LSB-") || str.equals("-RSB-") || str.equals("''")) {
return wf.getOffset() + 1;
}
return wf.getOffset() + wf.getLength();
}
示例5: applyEntityRemoveOverlaps
import ixa.kaflib.Term; //导入方法依赖的package包/类
private void applyEntityRemoveOverlaps(final KAFDocument document) {
// Consider all the entities in the document
outer: for (final Entity entity : ImmutableList.copyOf(document.getEntities())) {
for (final Term term : entity.getTerms()) {
// Remove entities whose span is contained in the span of another entity
for (final Entity entity2 : document.getEntitiesByTerm(term)) {
if (entity2 != entity && entity2.getTerms().containsAll(entity.getTerms())) {
document.removeAnnotation(entity);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Removed " + NAFUtils.toString(entity)
+ " overlapping with " + NAFUtils.toString(entity2));
}
continue outer;
}
}
// Remove entities whose span overlaps with the span of some timex
for (final WF wf : term.getWFs()) {
final List<Timex3> timex = document.getTimeExsByWF(wf);
if (!timex.isEmpty()) {
document.removeAnnotation(entity);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Removed " + NAFUtils.toString(entity)
+ " overlapping with TIMEX3 '" + NAFUtils.toString(timex));
}
continue outer;
}
}
}
}
}
示例6: getText
import ixa.kaflib.Term; //导入方法依赖的package包/类
private static String getText(final List<Term> terms) {
final StringBuilder builder = new StringBuilder();
boolean atBeginning = true;
for (final Term term : terms) {
for (final WF word : term.getWFs()) {
final String s = word.getForm();
final boolean punct = ",".equals(s) || ";".equals(s) || ".".equals(s)
|| ":".equals(s);
builder.append(atBeginning || punct ? "" : " ");
builder.append(word.getForm());
atBeginning = false;
}
}
return builder.toString();
}
示例7: getNominalSpan
import ixa.kaflib.Term; //导入方法依赖的package包/类
public static Span<Term> getNominalSpan(final KAFDocument document, final Term term,
final boolean includeCoord, final boolean includeModifiers) {
// Start from the supplied term
final Set<Term> terms = Sets.newHashSet(term);
// Identify head and terms of all NE and TIMEX markables containing supplied term
final Map<Term, List<Term>> markables = Maps.newHashMap();
for (final Entity entity : document.getEntitiesByTerm(term)) {
markables.put(document.getTermsHead(entity.getTerms()), entity.getTerms());
}
for (final WF wf : term.getWFs()) {
for (final Timex3 timex : document.getTimeExsByWF(wf)) {
final List<Term> span = document.getTermsByWFs(timex.getSpan().getTargets());
markables.put(document.getTermsHead(span), span);
}
}
// Add the terms of the smallest markable 'matching' the term (i.e., whose head matches
// the term or a term ancestor in the dependency tree)
if (!markables.isEmpty()) {
Term t = term;
while (true) {
final List<Term> parent = markables.get(t);
if (parent != null) {
terms.addAll(parent);
break;
}
final Dep dep = document.getDepToTerm(t);
if (dep == null) {
break;
}
t = dep.getFrom();
}
}
// Identify head
final Term head = document.getTermsHead(terms);
// Add all terms reachable from the head using a regex
final String regex = includeCoord ? includeModifiers ? "(COORD CONJ?)* ((NAME|NMOD|AMOD|TMP) .*)?"
: "(COORD CONJ?)* NAME"
: includeModifiers ? "((NAME|NMOD|AMOD|TMP) .*)?" : "NAME";
terms.addAll(document.getTermsByDepAncestors(Collections.singleton(head), regex));
// Sort obtained terms by offset and return resulting list
return KAFDocument.newTermSpan(Ordering.from(Term.OFFSET_COMPARATOR).sortedCopy(terms),
head);
}