本文整理汇总了Java中org.apache.uima.fit.util.FSCollectionFactory.fillArrayFS方法的典型用法代码示例。如果您正苦于以下问题:Java FSCollectionFactory.fillArrayFS方法的具体用法?Java FSCollectionFactory.fillArrayFS怎么用?Java FSCollectionFactory.fillArrayFS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.fit.util.FSCollectionFactory
的用法示例。
在下文中一共展示了FSCollectionFactory.fillArrayFS方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addParse
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
@Override
public TreebankNode addParse(
JCas jCas,
Parse parse,
SENTENCE_TYPE sentence,
List<TOKEN_TYPE> tokens) {
TopTreebankNode node = new TopTreebankNode(jCas);
this.setAttributes(node, parse, null, jCas);
node.addToIndexes();
StringBuffer sb = new StringBuffer();
parse.show(sb);
node.setTreebankParse(sb.toString());
List<TreebankNode> terminals = getTerminals(node);
node.setTerminals(new FSArray(jCas, terminals.size()));
FSCollectionFactory.fillArrayFS(node.getTerminals(), terminals);
return node;
}
示例2: makePredicate
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
Predicate makePredicate() {
if (this.predicateToken == null) {
throw new RuntimeException("no predicateToken found yet");
}
Predicate predicate = new Predicate(
jCas,
this.predicateToken.getBegin(),
this.predicateToken.getEnd());
predicate.setAnnotation(this.predicateToken);
predicate.setArguments(new FSArray(jCas, this.arguments.size()));
FSCollectionFactory.fillArrayFS(predicate.getArguments(), this.arguments);
predicate.setBaseForm(this.baseForm);
predicate.addToIndexes();
return predicate;
}
示例3: convert
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
/**
* Convert to ClearTK <em>Predicate</em> / <em>SemanticArgument</em> annotations and add them to
* <b>view</b>.
*
* @param view
* the view where the annotations should be added
* @param topNode
* the top node annotation of the corresponding Treebank parse
* @param sentence
* the sentence annotation of the corresponding sentence
* @return the generated <em>Predicate</em> annotation
*/
public Predicate convert(JCas view, TopTreebankNode topNode, Sentence sentence) {
Predicate p = new Predicate(view);
p.setPropTxt(this.propTxt);
p.setAnnotation(this.terminal.convert(view, topNode));
p.setBegin(p.getAnnotation().getBegin());
p.setEnd(p.getAnnotation().getEnd());
p.setSentence(sentence);
p.setFrameSet(this.frameSet);
p.setBaseForm(this.baseForm);
List<Argument> aList = new ArrayList<Argument>();
for (Proplabel proplabel : this.proplabels) {
aList.add(proplabel.convert(view, topNode));
}
p.setArguments(new FSArray(view, aList.size()));
FSCollectionFactory.fillArrayFS(p.getArguments(), aList);
p.addToIndexes();
return p;
}
示例4: addParse
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
@Override
public TopTreebankNode addParse(
JCas jCas,
Tree<String> berkeleyNode,
SENTENCE_TYPE sentence,
List<TOKEN_TYPE> tokens) {
List<TerminalTreebankNode> leafNodes = new ArrayList<TerminalTreebankNode>();
TopTreebankNode topNode = (TopTreebankNode) convertNode(
jCas,
berkeleyNode,
tokens,
new TokenIndex(),
leafNodes,
true);
topNode.setTerminals(new FSArray(jCas, leafNodes.size()));
FSCollectionFactory.fillArrayFS(topNode.getTerminals(), leafNodes);
topNode.addToIndexes();
return topNode;
}
示例5: setHeadRelations
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
@Override
public void setHeadRelations(
JCas jCas,
DependencyNode node,
List<DependencyRelation> headRelations) {
node.setHeadRelations(new FSArray(jCas, headRelations.size()));
FSCollectionFactory.fillArrayFS(node.getHeadRelations(), headRelations);
}
示例6: setChildRelations
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
@Override
public void setChildRelations(
JCas jCas,
DependencyNode node,
List<DependencyRelation> childRelations) {
node.setChildRelations(new FSArray(jCas, childRelations.size()));
FSCollectionFactory.fillArrayFS(node.getChildRelations(), childRelations);
}
示例7: setAttributes
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
private void setAttributes(TreebankNode node, Parse parse, TreebankNode parent, JCas jCas) {
node.setParent(parent);
node.setNodeType(parse.getType());
node.setBegin(parse.getSpan().getStart());
node.setEnd(parse.getSpan().getEnd());
// leaf node
if (isLeaf(parse)) {
node.setLeaf(true);
node.setNodeValue(parse.getChildren()[0].toString());
node.setChildren(new FSArray(jCas, 0));
}
// branch node
else {
node.setLeaf(false);
node.setNodeValue(null);
List<TreebankNode> childNodes = new ArrayList<TreebankNode>();
for (Parse childParse : parse.getChildren()) {
TreebankNode childNode = isLeaf(childParse)
? new TerminalTreebankNode(jCas)
: new TreebankNode(jCas);
this.setAttributes(childNode, childParse, node, jCas);
childNode.addToIndexes();
childNodes.add(childNode);
}
node.setChildren(new FSArray(jCas, childNodes.size()));
FSCollectionFactory.fillArrayFS(node.getChildren(), childNodes);
}
}
示例8: convert
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的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;
}
示例9: makeTreebankNode
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
public TreebankNode makeTreebankNode(JCas jCas) {
if (this.type.equals("S1")) {
return this.children.get(0);
} else {
int[] span = AnnotationUtil.getAnnotationsExtent(this.children);
TreebankNode node = new TreebankNode(jCas, span[0], span[1]);
node.setNodeType(this.type);
node.setChildren(new FSArray(jCas, this.children.size()));
FSCollectionFactory.fillArrayFS(node.getChildren(), this.children);
for (TreebankNode child : this.children)
child.setParent(node);
node.addToIndexes();
return node;
}
}
示例10: makeParse
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
public TopTreebankNode makeParse() {
int[] span = AnnotationUtil.getAnnotationsExtent(this.terminals);
TopTreebankNode node = new TopTreebankNode(jCas, span[0], span[1]);
node.setNodeType("TOP");
List<TreebankNode> children = parseStack.peek().children;
node.setChildren(new FSArray(jCas, children.size()));
FSCollectionFactory.fillArrayFS(node.getChildren(), children);
for (TreebankNode child : parseStack.peek().children)
child.setParent(node);
node.setTerminals(new FSArray(jCas, this.terminals.size()));
FSCollectionFactory.fillArrayFS(node.getTerminals(), this.terminals);
node.addToIndexes();
parseStack.pop();
return node;
}
示例11: setPredicateArguments
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
@Override
public void setPredicateArguments(JCas jCas, Predicate predicate, List<SemanticArgument> arguments) {
predicate.setArguments(new FSArray(jCas, arguments.size()));
FSCollectionFactory.fillArrayFS(predicate.getArguments(), arguments);
}
示例12: process
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
try {
String apfUri = jCas.getView(Ace2005Constants.ACE_2005_APF_URI_VIEW).getSofaDataURI();
JCas initialView = jCas.getView(CAS.NAME_DEFAULT_SOFA);
String documentText = initialView.getDocumentText();
SAXBuilder builder = new SAXBuilder();
builder.setDTDHandler(null);
URI sofaDataURI = new URI(apfUri);
Document doc = builder.build(new File(sofaDataURI));
Element apfSource = doc.getRootElement();
Element apfDocument = apfSource.getChild("document");
for (Element apfEntity : apfDocument.getChildren("entity")) {
NamedEntity namedEntity = new NamedEntity(initialView);
namedEntity.setEntityType(apfEntity.getAttributeValue("TYPE"));
namedEntity.setEntitySubtype(apfEntity.getAttributeValue("SUBTYPE"));
namedEntity.setEntityClass(apfEntity.getAttributeValue("CLASS"));
namedEntity.setEntityId(apfEntity.getAttributeValue("ID"));
namedEntity.addToIndexes();
List<NamedEntityMention> mentions = new ArrayList<NamedEntityMention>();
for (Element entityMention : apfEntity.getChildren("entity_mention")) {
int start = Integer.parseInt(entityMention.getChild("extent").getChild("charseq").getAttributeValue(
"START"));
int end = Integer.parseInt(entityMention.getChild("extent").getChild("charseq").getAttributeValue(
"END"));
String givenText = entityMention.getChild("extent").getChild("charseq").getText();
String parsedText = documentText.substring(start, end + 1);
Matcher ampMatcher = ampPattern.matcher(parsedText);
parsedText = ampMatcher.replaceAll("&");
NamedEntityMention mention = new NamedEntityMention(initialView, start, end + 1);
mention.setMentionId(entityMention.getAttributeValue("ID"));
mention.setMentionType(entityMention.getAttributeValue("TYPE"));
mention.setMentionedEntity(namedEntity);
Chunk chunk = new Chunk(initialView, start, end + 1);
mention.setAnnotation(chunk);
int headStart = Integer.parseInt(entityMention.getChild("head").getChild("charseq").getAttributeValue(
"START"));
int headEnd = Integer.parseInt(entityMention.getChild("head").getChild("charseq").getAttributeValue(
"END"));
Chunk head = new Chunk(initialView, headStart, headEnd + 1);
mention.setHead(head);
mention.addToIndexes();
mentions.add(mention);
givenText = givenText.replaceAll("\\s+", " ");
parsedText = givenText.replaceAll("\\s+", " ");
// if(!givenText.equals(parsedText))
// {
//
// System.out.println("given text and parsed text differ.");
// System.out.println(givenText);
// System.out.println(parsedText);
// System.out.println(apfDocument.getAttributeValue("DOCID"));
// System.out.println(apfEntity.getAttributeValue("ID"));
// System.out.println(documentText);
// }
}
namedEntity.setMentions(new FSArray(jCas, mentions.size()));
FSCollectionFactory.fillArrayFS(namedEntity.getMentions(), mentions);
}
} catch (CASException ce) {
throw new AnalysisEngineProcessException(ce);
} catch (IOException ioe) {
throw new AnalysisEngineProcessException(ioe);
} catch (JDOMException je) {
throw new AnalysisEngineProcessException(je);
} catch (URISyntaxException use) {
throw new AnalysisEngineProcessException(use);
}
}
示例13: convert
import org.apache.uima.fit.util.FSCollectionFactory; //导入方法依赖的package包/类
/**
* Convert to ClearTK <em>SemanticArgument</em> annotation and add it to <b>view</b>.
*
* @param view
* the view where the annotation will be added
* @param topNode
* the top node annotation of the corresponding Treebank parse
* @return the generated <em>SemanticArgument</em> annotation
*/
public SemanticArgument convert(JCas view, TopTreebankNode topNode) {
SemanticArgument argument = new SemanticArgument(view);
argument.setPropTxt(this.propTxt);
argument.setLabel(this.label);
argument.setFeature(this.feature);
argument.setPreposition(this.preposition);
argument.setHyphenTag(this.hyphenTag);
if (this.relation instanceof PropbankCorefRelation) {
List<Annotation> annotations = new ArrayList<Annotation>();
List<Annotation> substantiveAnnotations = new ArrayList<Annotation>();
for (PropbankRelation rel : ((PropbankCorefRelation) this.relation).getCorefRelations()) {
Annotation a = rel.convert(view, topNode);
annotations.add(a);
if (a.getBegin() != a.getEnd()) {
substantiveAnnotations.add(a);
}
}
argument.setCoreferenceAnnotations(new FSArray(view, annotations.size()));
FSCollectionFactory.fillArrayFS(argument.getCoreferenceAnnotations(), annotations);
if (substantiveAnnotations.isEmpty()) {
Annotation lastAnnotation = annotations.get(annotations.size() - 1);
argument.setBegin(lastAnnotation.getBegin());
argument.setEnd(lastAnnotation.getEnd());
} else {
int[] extent = AnnotationUtil.getAnnotationsExtent(substantiveAnnotations);
argument.setBegin(extent[0]);
argument.setEnd(extent[1]);
}
if (substantiveAnnotations.size() == 1) {
argument.setAnnotation(substantiveAnnotations.get(0));
}
} else {
argument.setAnnotation(this.relation.convert(view, topNode));
argument.setBegin(argument.getAnnotation().getBegin());
argument.setEnd(argument.getAnnotation().getEnd());
}
argument.addToIndexes();
return argument;
}