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


Java Term.getWFs方法代码示例

本文整理汇总了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;
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:20,代码来源:NAFUtils.java

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

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

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

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

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

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


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