• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Term类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: applySRLRemoveUnknownPredicates

import ixa.kaflib.Term; //导入依赖的package包/类
private void applySRLRemoveUnknownPredicates(final KAFDocument document) {

        // Scan all predicates in the SRL layer
        for (final Predicate predicate : Lists.newArrayList(document.getPredicates())) {

            // Determine whether the predicate is a verb and thus which resource to check for>
            final Term head = document.getTermsHead(predicate.getTerms());
            final boolean isVerb = head.getPos().equalsIgnoreCase("V");
            final String resource = isVerb ? "propbank" : "nombank";

            // Predicate is invalid if its roleset is unknown in NomBank / PropBank
            for (final ExternalRef ref : NAFUtils.getRefs(predicate, resource, null)) {
                final String roleset = ref.getReference();
                if (isVerb && PropBank.getRoleset(roleset) == null || !isVerb
                        && NomBank.getRoleset(roleset) == null) {
                    document.removeAnnotation(predicate);
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("Removed " + NAFUtils.toString(predicate)
                                + " with unknown sense '" + roleset + "' in resource " + resource);
                    }
                    break;
                }
            }
        }
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:26,代码来源:NAFFilter.java


示例17: applySRLRoleLinking

import ixa.kaflib.Term; //导入依赖的package包/类
private void applySRLRoleLinking(final KAFDocument document) {

        // Process all the roles in the SRL layer
        for (final Predicate predicate : Lists.newArrayList(document.getPredicates())) {
            for (final Role role : predicate.getRoles()) {

                // Identify the role head. Skip if not found.
                final Term head = NAFUtils.extractHead(document, role.getSpan());
                if (head == null) {
                    continue;
                }

                // Identify the terms that can be linked
                final Set<Term> argTerms = document.getTermsByDepAncestors(
                        Collections.singleton(head), PARTICIPATION_REGEX);

                // Perform the linking, possible augmenting terms using coref info
                linkEntitiesTimexPredicates(document, role, role.getSpan(), argTerms,
                        this.srlRoleLinkingUsingCoref);
            }
        }
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:23,代码来源:NAFFilter.java


示例18: printToken

import ixa.kaflib.Term; //导入依赖的package包/类
public static void printToken(Appendable writer, Term token, int i, String last) throws IOException {
    writer.append(String.format("%d", i)).append("\t");
    writer.append(token.getForm()).append("\t");
    writer.append("_").append("\t");
    writer.append(token.getForm()).append("\t");
    writer.append("_").append("\t");
    writer.append(token.getMorphofeat()).append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append("_").append("\t");
    writer.append(last);
    writer.append("\n");

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


示例19: isValidOpinion

import ixa.kaflib.Term; //导入依赖的package包/类
private static boolean isValidOpinion(final Opinion opinion) {
	final OpinionTarget target = opinion.getOpinionTarget();
	final OpinionExpression exp = opinion.getOpinionExpression();
	if (exp != null && target != null && exp.getPolarity() != null && exp.getSpan() != null
			&& exp.getSpan().size() > 0 && target.getSpan() != null
			&& target.getSpan().size() > 0) {
		final int id = opinion.getOpinionTarget().getSpan().getTargets().get(0).getSent();
		for (final Term term : Iterables.concat(exp.getTerms(), target.getTerms())) {
			if (term.getSent() != id) {
				return false;
			}
		}
		if (normalizePolarity(exp.getPolarity()).equals("neutral")) {
			return false;
		}
		return true;
	}
	return false;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:20,代码来源:EvaluateOnStanford.java


示例20: label

import ixa.kaflib.Term; //导入依赖的package包/类
public Map<Term, Float> label(final KAFDocument document, final Term root) {

        // Identify candidate terms. For each of them, compute features and apply classifier to
        // determine whether candidate term should be selected and with what probability estimate
        // Return a map mapping selected terms to their probability estimates
        final Map<Term, Float> map = Maps.newHashMap();
        for (final Term term : candidates(document, root, this.posPrefixes)) {
            final Vector vector = features(document, root, term);
            final LabelledVector outVector = this.classifier.predict(true, vector);
            final float p = outVector.getProbability(SELECTED);
            if (outVector.getLabel() == SELECTED) {
                map.put(term, p >= 0.5f ? p : 0.5f);
            } else {
                map.put(term, p < 0.5f ? p : 0.5f);
            }
        }
        return map;
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:19,代码来源:LinkLabeller.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultMessageLogger类代码示例发布时间:2022-05-23
下一篇:
Java SLSConfiguration类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap