当前位置: 首页>>代码示例>>Java>>正文


Java Term类代码示例

本文整理汇总了Java中ixa.kaflib.Term的典型用法代码示例。如果您正苦于以下问题:Java Term类的具体用法?Java Term怎么用?Java Term使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Term类属于ixa.kaflib包,在下文中一共展示了Term类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractPOStags

import ixa.kaflib.Term; //导入依赖的package包/类
/**
 *     POS tags ngram extraction from a kaf document
 * 
 * @param int length : which 'n' use for 'n-grams' 
 * @param KAFDocument kafDoc : postagged kaf document to extract ngrams from.
 * @param boolean save : safe ngrams to file or not. 
 * @return TreeSet<String> return lemma ngrams of length length
 */
public TreeSet<String> extractPOStags(KAFDocument kafDoc, boolean save)
{
	TreeSet<String> result = new TreeSet<String>();
	for (Term term : kafDoc.getTerms())
	{
		String pos = "POS_"+term.getPos();
		// for good measure, test that the lemma is not already included as a feature
		if (! getAttIndexes().containsKey(pos))
		{
			addNumericFeature(pos);
			result.add(pos);
		}

	}
       return result;
}
 
开发者ID:Elhuyar,项目名称:Elixa,代码行数:25,代码来源:Features.java

示例2: indexMarkables

import ixa.kaflib.Term; //导入依赖的package包/类
private static Markable[] indexMarkables(final List<Term> terms,
        final Iterable<Markable> markables) {

    final Map<Term, Integer> termIndex = Maps.newHashMap();
    for (int i = 0; i < terms.size(); ++i) {
        termIndex.put(terms.get(i), i);
    }

    final Markable[] markableIndex = new Markable[terms.size()];
    for (final Markable markable : markables) {
        for (final Term term : markable.getTerms()) {
            final Integer index = termIndex.get(term);
            if (index != null) {
                markableIndex[index] = markable;
            }
        }
    }

    return markableIndex;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:21,代码来源:NafRenderUtils.java

示例3: SRLElement

import ixa.kaflib.Term; //导入依赖的package包/类
SRLElement(final SRLElement parent, final Object element, final boolean useProposition) {
    this.parent = parent;
    this.element = element;
    if (useProposition) {
        final Predicate predicate = (Predicate) element;
        final Set<Term> termSet = Sets.newHashSet();
        termSet.addAll(predicate.getTerms());
        for (final Role role : predicate.getRoles()) {
            termSet.addAll(role.getTerms());
        }
        this.terms = Ordering.from(Term.OFFSET_COMPARATOR).immutableSortedCopy(termSet);
    } else if (element instanceof Predicate) {
        this.terms = ((Predicate) element).getTerms();
    } else {
        this.terms = ((Role) element).getTerms();
    }
    this.begin = this.terms.get(0).getOffset();
    this.end = endOf(this.terms.get(this.terms.size() - 1));
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:20,代码来源:NafRenderUtils.java

示例4: 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;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:20,代码来源:NAFUtils.java

示例5: hasHead

import ixa.kaflib.Term; //导入依赖的package包/类
public static boolean hasHead(final KAFDocument document, final Object annotation,
        final Term head) {
    List<Span<Term>> spans;
    if (annotation instanceof Coref) {
        spans = ((Coref) annotation).getSpans();
    } else if (annotation instanceof Entity) {
        spans = ((Entity) annotation).getSpans();
    } else if (annotation instanceof Timex3) {
        spans = ImmutableList.of(KAFDocument.newTermSpan(document
                .getTermsByWFs(((Timex3) annotation).getSpan().getTargets())));
    } else if (annotation instanceof Predicate) {
        spans = ImmutableList.of(((Predicate) annotation).getSpan());
    } else if (annotation instanceof Role) {
        spans = ImmutableList.of(((Role) annotation).getSpan());
    } else {
        throw new IllegalArgumentException("Unsupported annotation: " + annotation);
    }
    for (final Span<Term> span : spans) {
        if (head == extractHead(document, span)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:25,代码来源:NAFUtils.java

示例6: getRefs

import ixa.kaflib.Term; //导入依赖的package包/类
private static List<ExternalRef> getRefs(final Object annotation) {
    List<ExternalRef> refs = ImmutableList.of();
    if (annotation instanceof Term) {
        refs = ((Term) annotation).getExternalRefs();
    } else if (annotation instanceof Entity) {
        refs = ((Entity) annotation).getExternalRefs();
    } else if (annotation instanceof Predicate) {
        refs = ((Predicate) annotation).getExternalRefs();
    } else if (annotation instanceof Role) {
        refs = ((Role) annotation).getExternalRefs();
    } else if (annotation instanceof Opinion) {
        refs = ((Opinion) annotation).getExternalRefs();
    } else if (annotation instanceof OpinionExpression) {
        refs = ((OpinionExpression) annotation).getExternalRefs();
    } else if (annotation instanceof OpinionTarget) {
        refs = ((OpinionTarget) annotation).getExternalRefs();
    } else if (annotation instanceof OpinionHolder) {
        refs = ((OpinionHolder) annotation).getExternalRefs();
    } else {
        throw new IllegalArgumentException("Unsupported annotation object: " + annotation);
    }
    return refs;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:24,代码来源:NAFUtils.java

示例7: termRangesFor

import ixa.kaflib.Term; //导入依赖的package包/类
public static List<Range> termRangesFor(final KAFDocument document, final Iterable<Term> terms) {
    final List<Range> ranges = Lists.newArrayList();
    int startIndex = -1;
    int lastIndex = -2;
    for (final Term term : Ordering.from(Term.OFFSET_COMPARATOR).sortedCopy(terms)) {
        final int termIndex = document.getTerms().indexOf(term);
        if (termIndex - lastIndex > 1) {
            if (startIndex >= 0) {
                ranges.add(Range.create(startIndex, lastIndex + 1));
            }
            startIndex = termIndex;
        }
        lastIndex = termIndex;
    }
    if (startIndex != -1 && lastIndex >= startIndex) {
        ranges.add(Range.create(startIndex, lastIndex + 1));
    }
    return ranges;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:20,代码来源:NAFUtils.java

示例8: rangesFor

import ixa.kaflib.Term; //导入依赖的package包/类
public static List<Range> rangesFor(final KAFDocument document, final Iterable<Term> terms) {
    final List<Range> ranges = Lists.newArrayList();
    int startOffset = -1;
    int endOffset = -1;
    int termIndex = -2;
    for (final Term term : Ordering.from(Term.OFFSET_COMPARATOR).sortedCopy(terms)) {
        final int lastTermIndex = termIndex;
        termIndex = document.getTerms().indexOf(term);
        if (termIndex - lastTermIndex > 1) {
            if (startOffset != -1) {
                ranges.add(Range.create(startOffset, endOffset));
            }
            startOffset = term.getOffset();
        }
        endOffset = NAFUtils.getEnd(term);
    }
    if (startOffset != -1 && endOffset > startOffset) {
        ranges.add(Range.create(startOffset, endOffset));
    }
    return ranges;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:22,代码来源:NAFUtils.java

示例9: splitSpan

import ixa.kaflib.Term; //导入依赖的package包/类
public static final List<Span<Term>> splitSpan(final KAFDocument document,
        final Span<Term> span, final Iterable<Term> heads) {

    final Set<Term> excludedTerms = document.getTermsByDepDescendants(heads);
    final List<Span<Term>> spans = Lists.newArrayList();
    for (final Term head : heads) {
        final Set<Term> terms = document.getTermsByDepAncestors(ImmutableSet.of(head));
        terms.removeAll(excludedTerms);
        terms.add(head);
        terms.retainAll(span.getTargets());
        if (!terms.isEmpty()) {
            spans.add(KAFDocument.newTermSpan(Ordering.from(Term.OFFSET_COMPARATOR)
                    .sortedCopy(terms), head));
        }
    }
    return spans;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:18,代码来源:NAFUtils.java

示例10: isActiveFormHelper

import ixa.kaflib.Term; //导入依赖的package包/类
private static Boolean isActiveFormHelper(final KAFDocument document, final Term term) {
    final Dep dep = document.getDepToTerm(term);
    if (dep == null) {
        return Boolean.FALSE;
    }
    final Term parent = dep.getFrom();
    final String word = parent.getStr().toLowerCase();
    final String pos = parent.getMorphofeat();
    if (pos.startsWith("NN")) {
        return Boolean.FALSE;
    }
    if (word.matches("am|are|is|was|were|be|been|being")) {
        return Boolean.FALSE;
    }
    if (word.matches("ha(ve|s|d|ving)")) {
        return Boolean.TRUE;
    }

    if (pos.matches("VBZ|VBD|VBP|MD")) {
        return Boolean.FALSE;
    }
    return isActiveFormHelper(document, parent);
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:24,代码来源:NAFUtils.java

示例11: matchExtendedPos

import ixa.kaflib.Term; //导入依赖的package包/类
public static java.util.function.Predicate<Term> matchExtendedPos(final KAFDocument document,
        final String... posPrefixes) {
    return new java.util.function.Predicate<Term>() {

        @Override
        public boolean test(final Term term) {
            final String pos = extendedPos(document, term);
            for (final String prefix : posPrefixes) {
                if (pos.startsWith(prefix)) {
                    return true;
                }
            }
            return false;
        }

    };
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:18,代码来源:NAFUtils.java

示例12: sentenceForSpan

import ixa.kaflib.Term; //导入依赖的package包/类
@Nullable
private static Integer sentenceForSpan(Span<Term> termSpan) {
	HashSet<Integer> sentences = new HashSet<>();
	for (Term term : termSpan.getTargets()) {
		sentences.add(term.getSent());
	}

	if (sentences.size() != 1) {
		return null;
	}

	for (Integer sentence : sentences) {
		return sentence;
	}

	return null;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:18,代码来源:JohanssonAnnotator.java

示例13: getSpan

import ixa.kaflib.Term; //导入依赖的package包/类
public static List<Term> getSpan(List<Term> terms, String interval) {
	if (interval == null) {
		return new ArrayList<Term>();
	}

	Matcher matcher = spanPatt.matcher(interval);
	if (!matcher.matches()) {
		return new ArrayList<Term>();
	}

	int start = Integer.parseInt(matcher.group(1));
	int end = Integer.parseInt(matcher.group(2)) - 1;

	LOGGER.debug("Start: " + start + " - End: " + end);
	return getSpan(terms, start, end);
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:17,代码来源:CorpusAnnotator.java

示例14: match

import ixa.kaflib.Term; //导入依赖的package包/类
public Multimap<Term, T> match(final KAFDocument document, final Iterable<Term> terms) {
	Preconditions.checkNotNull(document);
	final Set<Term> termSet = ImmutableSet.copyOf(terms);
	final Multimap<Term, T> result = HashMultimap.create();
	for (final Term term : termSet) {
		final String lemma = term.getLemma();
		final String stem = Stemming.stem(null, lemma);
		for (final T lexeme : ImmutableSet.copyOf(Iterables.concat(
				this.lemmaIndex.get(term.getLemma()), this.stemIndex.get(stem)))) {
			if (lexeme.match(document, termSet, term)) {
				result.put(term, lexeme);
			}
		}
	}
	return result;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:17,代码来源:Lexicon.java

示例15: getTermsFromSpan

import ixa.kaflib.Term; //导入依赖的package包/类
private static Span<Term> getTermsFromSpan(KAFDocument document, String span) {
	String[] parts = span.split("[^a-z0-9A-Z_]+");
	Span<Term> termSpan = KAFDocument.newTermSpan();

	if (parts.length == 1) {
		Integer id = getTermFromSpan(parts[0]);
		termSpan.addTarget(document.getTerms().get(id));
	}
	else if (parts.length > 1) {
		Integer id1 = getTermFromSpan(parts[0]);
		Integer id2 = getTermFromSpan(parts[parts.length - 1]);
		for (int i = id1; i <= id2; i++) {
			termSpan.addTarget(document.getTerms().get(i));
		}
	}

	return termSpan;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:19,代码来源:CorpusAnnotator.java


注:本文中的ixa.kaflib.Term类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。