本文整理了Java中org.apache.uima.jcas.cas.FSArray.get()
方法的一些代码示例,展示了FSArray.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FSArray.get()
方法的具体详情如下:
包路径:org.apache.uima.jcas.cas.FSArray
类名称:FSArray
方法名:get
[英]return the indexed value from the corresponding Cas FSArray as a Java Model object.
[中]作为Java模型对象从相应的Cas FSArray返回索引值。
代码示例来源:origin: apache/tika
if (mentions != null) {
for (int i = 0; i < mentions.size(); i++) {
if (mentions.get(i) instanceof UmlsConcept) {
UmlsConcept concept = (UmlsConcept) mentions.get(i);
sb.append("cui=").append(concept.getCui()).append(",").
append(concept.getCodingScheme()).append("=").
代码示例来源:origin: apache/uima-uimaj
@Override
public FeatureStructure next() {
if (!hasNext())
throw new NoSuchElementException();
return get(i++);
}
代码示例来源:origin: org.apache.ctakes/ctakes-constituency-parser
public static String getSplitSentence( final FSArray terminalArray ) {
// int offset = 0; // what was this for?
final StringBuilder sb = new StringBuilder();
for ( int i = 0; i < terminalArray.size(); i++ ) {
final TerminalTreebankNode ttn = (TerminalTreebankNode)terminalArray.get( i );
final String word = WHITESPACE_PATTERN.matcher( ttn.getNodeValue() ).replaceAll( "" );
// if(i == 0) offset = ttn.getBegin();
if ( !word.isEmpty() ) {
sb.append( " " ).append( word );
}
}
// Do we want to trim the first whitespace?
return sb.toString();
}
代码示例来源:origin: apache/ctakes
public static String getSplitSentence( final FSArray terminalArray ) {
// int offset = 0; // what was this for?
final StringBuilder sb = new StringBuilder();
for ( int i = 0; i < terminalArray.size(); i++ ) {
final TerminalTreebankNode ttn = (TerminalTreebankNode)terminalArray.get( i );
final String word = WHITESPACE_PATTERN.matcher( ttn.getNodeValue() ).replaceAll( "" );
// if(i == 0) offset = ttn.getBegin();
if ( !word.isEmpty() ) {
sb.append( " " ).append( word );
}
}
// Do we want to trim the first whitespace?
return sb.toString();
}
代码示例来源:origin: dstl/baleen
private List<Long> getInternalIds(final FSArray annotationArray) {
final List<Long> entities = new ArrayList<>();
for (int x = 0; x < annotationArray.size(); x++) {
final FeatureStructure featureStructure = annotationArray.get(x);
if (featureStructure != null && featureStructure instanceof BaleenAnnotation) {
final BaleenAnnotation ent = (BaleenAnnotation) featureStructure;
entities.add(ent.getInternalId());
}
}
return entities;
}
}
代码示例来源:origin: dstl/baleen
private List<String> getEntityIds(FSArray entityArray) {
List<String> entities = new ArrayList<>();
for (int x = 0; x < entityArray.size(); x++) {
FeatureStructure featureStructure = entityArray.get(x);
if (featureStructure instanceof Entity) {
Entity ent = (Entity) featureStructure;
entities.add(ent.getExternalId());
}
}
return entities;
}
代码示例来源:origin: CLLKazan/UIMA-Ext
@SuppressWarnings("unchecked")
public static <FST extends FeatureStructure> List<FST> toList(FSArray casArray,
Class<FST> fstClass) {
List<FST> result = newArrayListWithCapacity(casArray.size());
for (int i = 0; i < casArray.size(); i++) {
result.add((FST) casArray.get(i));
}
return result;
}
代码示例来源:origin: org.cleartk/cleartk-corpus
private static void _initTerminalNodes(
org.cleartk.syntax.constituent.type.TreebankNode node,
List<TerminalTreebankNode> terminals) {
FSArray children = node.getChildren();
for (int i = 0; i < children.size(); i++) {
org.cleartk.syntax.constituent.type.TreebankNode child = (org.cleartk.syntax.constituent.type.TreebankNode) children.get(i);
if (child instanceof TerminalTreebankNode) {
terminals.add((TerminalTreebankNode) child);
} else
_initTerminalNodes(child, terminals);
}
}
代码示例来源:origin: ClearTK/cleartk
private static void _initTerminalNodes(
org.cleartk.syntax.constituent.type.TreebankNode node,
List<TerminalTreebankNode> terminals) {
FSArray children = node.getChildren();
for (int i = 0; i < children.size(); i++) {
org.cleartk.syntax.constituent.type.TreebankNode child = (org.cleartk.syntax.constituent.type.TreebankNode) children.get(i);
if (child instanceof TerminalTreebankNode) {
terminals.add((TerminalTreebankNode) child);
} else
_initTerminalNodes(child, terminals);
}
}
代码示例来源:origin: org.apache.ctakes/ctakes-coreference
private static TreebankNode findP (TreebankNode n, String phraseTag, int startingChild) {
FSArray c = n.getChildren();
int i = startingChild;
while (i < c.size()) {
TreebankNode tn = (TreebankNode) c.get(i++);
if (tn.getNodeType().equals(phraseTag) ||
tn.getNodeType().startsWith(phraseTag+"-"))
return tn;
}
return null;
}
代码示例来源:origin: apache/ctakes
private static TreebankNode findP (TreebankNode n, String phraseTag, int startingChild) {
FSArray c = n.getChildren();
int i = startingChild;
while (i < c.size()) {
TreebankNode tn = (TreebankNode) c.get(i++);
if (tn.getNodeType().equals(phraseTag) ||
tn.getNodeType().startsWith(phraseTag+"-"))
return tn;
}
return null;
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-odin
private String getLemma(final WordToken token) {
final FSArray array = token.getLemmas();
if (array == null || array.size() == 0) {
return token.getCoveredText().toLowerCase();
} else {
return ((WordLemma) array.get(0)).getLemmaForm();
}
}
代码示例来源:origin: dstl/baleen
private String getLemma(final WordToken token) {
final FSArray array = token.getLemmas();
if (array == null || array.size() == 0) {
return token.getCoveredText().toLowerCase();
} else {
return ((WordLemma) array.get(0)).getLemmaForm();
}
}
代码示例来源:origin: org.apache.uima/ruta-core
private static int countRuleApplies(Annotation annotation) {
int result = 0;
if (annotation instanceof DebugBlockApply) {
DebugBlockApply dba = (DebugBlockApply) annotation;
FSArray innerApply = dba.getInnerApply();
for (int i = 0; i < innerApply.size(); i++) {
Annotation each = (Annotation) innerApply.get(i);
result += countRuleApplies(each);
}
} else if (annotation instanceof DebugRuleApply) {
DebugRuleApply dra = (DebugRuleApply) annotation;
result += dra.getApplied();
}
return result;
}
代码示例来源:origin: dstl/baleen
@Test
public void testEventHasCorrectEntitiesWhenUsingSentences()
throws AnalysisEngineProcessException, ResourceInitializationException {
processJCas();
Iterator<Event> eventIterator = JCasUtil.select(jCas, Event.class).iterator();
Event firstEvent = eventIterator.next();
Event secondEvent = eventIterator.next();
Entity firstEntity = (Entity) firstEvent.getEntities().get(0);
Entity secondEntity = (Entity) secondEvent.getEntities().get(0);
if (firstEntity instanceof Person) {
assertTrue(secondEntity instanceof Chemical);
} else if (firstEntity instanceof Chemical) {
assertTrue(secondEntity instanceof Person);
} else {
fail("Should be 1 entity of type Person and another of type Chemical");
}
}
代码示例来源:origin: org.apache.ctakes/ctakes-constituency-parser
/**
* @param sentenceOffset begin offest character index for sentence
* @param text text of the sentence
* @param terminalArray [token] terminals in the sentence
* @return open nlp Parse
*/
public static Parse ctakesTokensToOpennlpTokens( final int sentenceOffset, final String text,
final FSArray terminalArray ) {
// based on the first part of parseLine in the opennlp libraries
final Parse sentenceParse = new Parse( text, new Span( 0, text
.length() ), AbstractBottomUpParser.INC_NODE, 0, 0 );
for ( int i = 0; i < terminalArray.size(); i++ ) {
final TerminalTreebankNode token = (TerminalTreebankNode)terminalArray.get( i );
final Span span = new Span( token.getBegin() - sentenceOffset, token.getEnd() - sentenceOffset );
sentenceParse.insert( new Parse( text, span, AbstractBottomUpParser.TOK_NODE, 0, i ) );
}
return sentenceParse;
}
代码示例来源:origin: apache/ctakes
/**
* @param sentenceOffset begin offest character index for sentence
* @param text text of the sentence
* @param terminalArray [token] terminals in the sentence
* @return open nlp Parse
*/
public static Parse ctakesTokensToOpennlpTokens( final int sentenceOffset, final String text,
final FSArray terminalArray ) {
// based on the first part of parseLine in the opennlp libraries
final Parse sentenceParse = new Parse( text, new Span( 0, text
.length() ), AbstractBottomUpParser.INC_NODE, 0, 0 );
for ( int i = 0; i < terminalArray.size(); i++ ) {
final TerminalTreebankNode token = (TerminalTreebankNode)terminalArray.get( i );
final Span span = new Span( token.getBegin() - sentenceOffset, token.getEnd() - sentenceOffset );
sentenceParse.insert( new Parse( text, span, AbstractBottomUpParser.TOK_NODE, 0, i ) );
}
return sentenceParse;
}
代码示例来源:origin: dstl/baleen
@Test
public void testToList() {
assertTrue(UimaTypesUtils.toList((StringArray) null).isEmpty());
assertTrue(UimaTypesUtils.toList((FSArray) null).isEmpty());
// Empty list
FSArray array = new FSArray(jCas, 2);
assertEquals(2, UimaTypesUtils.toList(array).size());
// Populate
array.set(0, new Entity(jCas));
array.set(1, new Entity(jCas));
List<Entity> list = UimaTypesUtils.toList(array);
assertEquals(2, list.size());
assertSame(array.get(0), list.get(0));
assertSame(array.get(0), list.get(0));
}
}
代码示例来源:origin: dstl/baleen
@Test
public void testToFSArrayCollection() {
FSArray nullArray = UimaTypesUtils.toFSArray(jCas, (Collection<FeatureStructure>) null);
assertNotNull(nullArray);
assertEquals(0, nullArray.size());
FSArray emptyArray = UimaTypesUtils.toFSArray(jCas, new ArrayList<>());
assertNotNull(emptyArray);
assertEquals(0, emptyArray.size());
Entity e = new Entity(jCas);
FSArray fullArray = UimaTypesUtils.toFSArray(jCas, Arrays.asList(e));
assertNotNull(fullArray);
assertEquals(1, fullArray.size());
assertSame(e, fullArray.get(0));
}
代码示例来源:origin: dstl/baleen
@Test
public void testToFSArrayFeatureStructure() {
FSArray nullArray = UimaTypesUtils.toFSArray(jCas, (FeatureStructure) null);
assertNotNull(nullArray);
assertEquals(1, nullArray.size());
FSArray emptyArray = UimaTypesUtils.toFSArray(jCas);
assertNotNull(emptyArray);
assertEquals(0, emptyArray.size());
Entity e = new Entity(jCas);
FSArray fullArray = UimaTypesUtils.toFSArray(jCas, e);
assertNotNull(fullArray);
assertEquals(1, fullArray.size());
assertSame(e, fullArray.get(0));
}
内容来源于网络,如有侵权,请联系作者删除!