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


Java Dependency类代码示例

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


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

示例1: makeDepParse

import edu.jhu.hlt.concrete.Dependency; //导入依赖的package包/类
private DependencyParse makeDepParse(int[] parents, List<String> depRels) {
    if(depRels != null && parents.length != depRels.size()) {
        throw new IllegalArgumentException("Parents length doesn't match depRels length");
    }
    DependencyParse p = new DependencyParse();
    p.setUuid(getUUID());
    AnnotationMetadata meta = new AnnotationMetadata();
    meta.setTool(DEP_PARSE_TOOL);
    meta.setTimestamp(timestamp);
    p.setMetadata(meta);
    p.setDependencyList(new ArrayList<Dependency>());
    for(int i=0; i<parents.length; i++) {
        if (parents[i] == -2) { continue; }
        Dependency d = new Dependency();
        d.setDep(i);
        d.setGov(parents[i]);
        if (depRels != null && depRels.get(i) != null) {
            d.setEdgeType(depRels.get(i));
        }
        p.addToDependencyList(d);
    }
    return p;
}
 
开发者ID:mgormley,项目名称:pacaya-nlp,代码行数:24,代码来源:ConcreteWriter.java

示例2: makeDependencyParse

import edu.jhu.hlt.concrete.Dependency; //导入依赖的package包/类
private DependencyParse makeDependencyParse(SrlGraph srl, AnnoSentence from, AnnotationMetadata meta) {
    DependencyParse p = new DependencyParse();
    p.setUuid(getUUID());
    p.setMetadata(meta);
    p.setDependencyList(new ArrayList<Dependency>());
    for(SrlPred pred : srl.getPreds()) {
        {
            Dependency d = new Dependency();
            d.setGov(-1);
            d.setDep(pred.getPosition());
            d.setEdgeType(pred.getLabel());
            p.addToDependencyList(d);
        }
        for(SrlEdge e : pred.getEdges()) {
            Dependency ed = new Dependency();
            ed.setGov(pred.getPosition());
            ed.setDep(e.getArg().getPosition());
            ed.setEdgeType(e.getLabel());
            p.addToDependencyList(ed);
        }
    }
    return p;
}
 
开发者ID:mgormley,项目名称:pacaya-nlp,代码行数:24,代码来源:ConcreteWriter.java

示例3: addDepParse

import edu.jhu.hlt.concrete.Dependency; //导入依赖的package包/类
private static void addDepParse(Tokenization tokenization, String toolName, int[] parents) {
    List<Dependency> depList = new ArrayList<>();
    int dep = 0;
    for (int gov : parents) {
        Dependency d = new Dependency();
        d.setEdgeType("l"+dep);
        d.setGov(gov);
        d.setDep(dep++);
        depList.add(d);
    }
    DependencyParse dp = new DependencyParse();
    dp.setUuid(getUUID());
    dp.setDependencyList(depList);
    dp.setMetadata(getMetadata(toolName));
    tokenization.addToDependencyParseList(dp);
}
 
开发者ID:mgormley,项目名称:pacaya-nlp,代码行数:17,代码来源:ConcreteReaderTest.java

示例4: makeDepParse

import edu.jhu.hlt.concrete.Dependency; //导入依赖的package包/类
private DependencyParse makeDepParse(SemanticGraph semGraph, UUID tokenizationUUID, String toolName) {
  DependencyParse depParse = new DependencyParse();
  depParse.setUuid(this.gen.next());
  TheoryDependencies td = new TheoryDependencies();
  td.addToTokenizationTheoryList(tokenizationUUID);
  AnnotationMetadata md = new AnnotationMetadata(toolName, Timing.currentLocalTime(), 1);
  depParse.setMetadata(md);
  List<Dependency> dependencies = makeDependencies(semGraph);
  depParse.setDependencyList(dependencies);
  return depParse;
}
 
开发者ID:hltcoe,项目名称:concrete-stanford-deprecated2,代码行数:12,代码来源:PreNERCoreMapWrapper.java

示例5: getObservedBasicDependencies

import edu.jhu.hlt.concrete.Dependency; //导入依赖的package包/类
public static Set<String> getObservedBasicDependencies(Communication c) {
  Set<String> deps = new HashSet<>();
  Assert.assertEquals(c.getSectionListSize(), 1);
  Section sect = c.getSectionList().get(0);
  Tokenization toks = sect
      .getSentenceList().get(0).getTokenization();
  Assert.assertNotNull(toks);
  Assert.assertNotNull(toks.getDependencyParseList());
  List<DependencyParse> dps = toks.getDependencyParseList()
      .stream()
      .filter(dp -> dp.getMetadata().getTool().contains("basic"))
      .collect(Collectors.toList());
  Assert.assertEquals(1, dps.size());
  for (Dependency e : dps.get(0).getDependencyList()) {
    Assert.assertTrue(e.getDep() >= 0);
    List<Token> tokList = toks.getTokenList().getTokenList();
    Token word = tokList.get(e.getDep());
    String h = "ROOT-0";
    if (e.isSetGov() && e.getGov() >= 0) {
      h = String.format("%s-%d", tokList.get(e.getGov()).getText(), e.getGov() + 1);
    }
    String dep = String.format("%s(%s, %s-%d)",
        e.getEdgeType(),
        h,
        word.getText(),
        e.getDep() + 1);
    deps.add(dep);
  }
  return deps;
}
 
开发者ID:hltcoe,项目名称:concrete-stanford-deprecated2,代码行数:31,代码来源:BasicDepParseTest.java

示例6: getParentsDeprels

import edu.jhu.hlt.concrete.Dependency; //导入依赖的package包/类
private static Pair<int[],List<String>> getParentsDeprels(DependencyParse dependencyParse, int numWords) {
    if (dependencyParse == null) {
        return null;
    }
    // Parents.
    int[] parents = new int[numWords];
    Arrays.fill(parents, -2);
    // Labels.
    List<String> deprels = new ArrayList<>(numWords);
    for (int i=0; i<numWords; i++) {
        deprels.add(null);
    }
    for (Dependency arc : dependencyParse.getDependencyList()) {
        // Parent.
        int c = arc.getDep();
        if (c < 0) {
            throw new IllegalStateException(String.format("Invalid dep value %d for dependendency tree %s", arc.getDep(), dependencyParse.getUuid()));
        }
        if (parents[c] != -2) {
            throw new IllegalStateException("Multiple parents for token: " + dependencyParse);
        }
        if (!arc.isSetGov()) {
            parents[c] = -1;
        } else {
            parents[c] = arc.getGov();
        }
        // Label.
        deprels.set(c, arc.getEdgeType());
    }
    if (IntArrays.contains(parents, -2)) {
        log.trace("Dependency tree contains token(s) with no head: " + dependencyParse.getUuid());
    }
    return new Pair<int[],List<String>>(parents, deprels);
}
 
开发者ID:mgormley,项目名称:pacaya-nlp,代码行数:35,代码来源:ConcreteReader.java

示例7: create

import edu.jhu.hlt.concrete.Dependency; //导入依赖的package包/类
/**
 *
 * @param dependentTokenIdx the dependent token index
 * @return a {@link Dependency} with the dep field set
 */
public static final Dependency create(final int dependentTokenIdx) {
  return new Dependency().setDep(dependentTokenIdx);
}
 
开发者ID:hltcoe,项目名称:concrete-java,代码行数:9,代码来源:DependencyFactory.java


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