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


Java FSArray.copyFromArray方法代码示例

本文整理汇总了Java中org.apache.uima.jcas.cas.FSArray.copyFromArray方法的典型用法代码示例。如果您正苦于以下问题:Java FSArray.copyFromArray方法的具体用法?Java FSArray.copyFromArray怎么用?Java FSArray.copyFromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.jcas.cas.FSArray的用法示例。


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

示例1: initTerminalNodes

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static void initTerminalNodes(
    org.cleartk.syntax.constituent.type.TopTreebankNode uimaNode,
    JCas jCas) {
  List<TerminalTreebankNode> terminals = new ArrayList<org.cleartk.syntax.constituent.type.TerminalTreebankNode>();
  _initTerminalNodes(uimaNode, terminals);

  for (int i = 0; i < terminals.size(); i++) {
    TerminalTreebankNode terminal = terminals.get(i);
    terminal.setIndex(i);
  }

  FSArray terminalsFSArray = new FSArray(jCas, terminals.size());
  terminalsFSArray.copyFromArray(
      terminals.toArray(new FeatureStructure[terminals.size()]),
      0,
      0,
      terminals.size());
  uimaNode.setTerminals(terminalsFSArray);
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:20,代码来源:TreebankNodeConverter.java

示例2: newNode

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
 * Create a branch TreebankNode in a JCas. The offsets of this node will be determined by its
 * children.
 * 
 * @param jCas
 *          The JCas which the annotation should be added to.
 * @param nodeType
 *          The phrase type tag of the node.
 * @param children
 *          The TreebankNode children of the node.
 * @return The TreebankNode which was added to the JCas.
 */
public static TreebankNode newNode(JCas jCas, String nodeType, TreebankNode... children) {
  int begin = children[0].getBegin();
  int end = children[children.length - 1].getEnd();
  TreebankNode node = new TreebankNode(jCas, begin, end);
  node.setNodeType(nodeType);
  node.addToIndexes();
  FSArray fsArray = new FSArray(jCas, children.length);
  fsArray.copyFromArray(children, 0, 0, children.length);
  node.setChildren(fsArray);
  for (TreebankNode child : children) {
    child.setParent(node);
  }
  return node;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:27,代码来源:TreebankNodeUtil.java

示例3: convert

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static org.cleartk.syntax.constituent.type.TreebankNode convert(
    TreebankNode pojoNode,
    JCas jCas,
    org.cleartk.syntax.constituent.type.TreebankNode uimaNode,
    org.cleartk.syntax.constituent.type.TreebankNode parentNode,
    boolean addToIndexes) {
  uimaNode.setNodeType(pojoNode.getType());
  StringArray nodeTags = (StringArray) (FSCollectionFactory.fillArrayFS(new StringArray(
      jCas,
      pojoNode.getTags().length), pojoNode.getTags()));
  uimaNode.setNodeTags(nodeTags);
  uimaNode.setNodeValue(pojoNode.getValue());
  uimaNode.setLeaf(pojoNode.isLeaf());
  uimaNode.setParent(parentNode);

  List<org.cleartk.syntax.constituent.type.TreebankNode> uimaChildren = new ArrayList<org.cleartk.syntax.constituent.type.TreebankNode>();
  for (TreebankNode child : pojoNode.getChildren()) {
    org.cleartk.syntax.constituent.type.TreebankNode childNode;
    if (child.isLeaf()) {
      childNode = new TerminalTreebankNode(jCas, child.getTextBegin(), child.getTextEnd());
    } else {
      childNode = new org.cleartk.syntax.constituent.type.TreebankNode(
          jCas,
          child.getTextBegin(),
          child.getTextEnd());
    }
    uimaChildren.add(convert(child, jCas, childNode, uimaNode, addToIndexes));
    if (addToIndexes)
      childNode.addToIndexes();
  }
  FSArray uimaChildrenFSArray = new FSArray(jCas, uimaChildren.size());
  uimaChildrenFSArray.copyFromArray(
      uimaChildren.toArray(new FeatureStructure[uimaChildren.size()]),
      0,
      0,
      uimaChildren.size());
  uimaNode.setChildren(uimaChildrenFSArray);
  return uimaNode;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:40,代码来源:TreebankNodeConverter.java

示例4: recordObservationInCas

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
private void recordObservationInCas(final JCas aCAS, final String term,
                                    final List<AnnotationFS> observations, final String docUri) {
    final Term tfAnnotation = new Term(aCAS);
    tfAnnotation.setSurface(term);
    final int frequency = observations.size();
    tfAnnotation.setCasFrequency(frequency);
    final int numObs = observations.size();
    final FSArray observationsFS = new FSArray(aCAS, numObs);
    final AnnotationFS[] observationsArr = new AnnotationFS[numObs];
    observations.toArray(observationsArr);
    observationsFS.copyFromArray(observationsArr, 0, 0, numObs);
    tfAnnotation.setObservations(observationsFS);
    tfAnnotation.addToIndexes();
    documentFrequencies.observe(term,new TermFreqRecord(numObs, docUri));
}
 
开发者ID:adimit,项目名称:summarization,代码行数:16,代码来源:TermFrequency.java

示例5: process

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public void process(JCas jCas) throws AnalysisEngineProcessException {
  // The text here was once upon a time some lyrics by a favorite singer which have since been
  // obfuscated to avoid any copyright issues.
  jCas.setDocumentText("Wwwwwwww ii ss yyy mmmmm ttttt yyy hhhh " + "Yyy hhhh nnnnnnn tt llll "
      + "Ttttttt eeeee dddd aaa llllll ttttt " + "Tttt rrrr llll a ffff.");
  Token token1 = new Token(jCas, 0, 8);
  token1.addToIndexes();
  Lemma lemma = new Lemma(jCas);
  lemma.setValue("wwwwwwww");
  // covered text of lemma is "hat"
  lemma.setBegin(1);
  lemma.setEnd(4);
  lemma.setTestFS(new StringArray(jCas, 3));
  lemma.setTestFS(0, "A");
  lemma.setTestFS(1, "B");
  lemma.setTestFS(2, "A");

  lemma.addToIndexes();
  token1.setLemma(lemma);
  PosTag posTag1 = new PosTag(jCas, 0, 8);
  posTag1.setValue("pos1");
  posTag1.addToIndexes();
  PosTag posTag2 = new PosTag(jCas, 0, 8);
  posTag2.setValue("pos2");
  posTag2.addToIndexes();
  FSArray token1Poses = new FSArray(jCas, 2);
  token1Poses.copyFromArray(new FeatureStructure[] { posTag1, posTag2 }, 0, 0, 2);
  token1.setPosTag(token1Poses);

  Token token2 = new Token(jCas, 9, 11);
  token2.addToIndexes();
  PosTag posTag3 = new PosTag(jCas);
  posTag3.setValue("pos3");
  posTag3.addToIndexes();
  FSArray token2Poses = new FSArray(jCas, 1);
  token2Poses.copyFromArray(new FeatureStructure[] { posTag3 }, 0, 0, 1);
  token2.setPosTag(token2Poses);

  Token token3 = new Token(jCas, 12, 14);
  token3.addToIndexes();

  DependencyRelation depRel1 = new DependencyRelation(jCas);
  depRel1.setHead(token1);
  depRel1.setProjective(true);
  depRel1.setLabel("deprel token1");
  depRel1.addToIndexes();
  DependencyRelation depRel2 = new DependencyRelation(jCas);
  depRel2.setHead(token2);
  depRel2.setProjective(true);
  depRel2.setLabel("deprel token2");
  depRel2.addToIndexes();
  FSArray depRels = new FSArray(jCas, 2);
  depRels.copyFromArray(new FeatureStructure[] { depRel1, depRel2 }, 0, 0, 2);
  token3.setDepRel(depRels);

}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:57,代码来源:TypePathExtractorTest.java


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