本文整理汇总了Java中org.uimafit.util.JCasUtil.selectSingle方法的典型用法代码示例。如果您正苦于以下问题:Java JCasUtil.selectSingle方法的具体用法?Java JCasUtil.selectSingle怎么用?Java JCasUtil.selectSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.uimafit.util.JCasUtil
的用法示例。
在下文中一共展示了JCasUtil.selectSingle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertCasToPairData
import org.uimafit.util.JCasUtil; //导入方法依赖的package包/类
/**
* Converts a JCas created by an EOP LAP, to BIU's PairData.
* @param jcas
* @return
* @throws CasTreeConverterException
* @throws UnsupportedPosTagStringException
* @throws CASException
* @throws EDAException
*/
public static PairData convertCasToPairData(JCas jcas) throws CasTreeConverterException, UnsupportedPosTagStringException, CASException, EDAException {
Pair pairAnno = JCasUtil.selectSingle(jcas, Pair.class);
Text textAnno = pairAnno.getText();
Hypothesis hypothesisAnno = pairAnno.getHypothesis();
JCas textView = jcas.getView(LAP_ImplBase.TEXTVIEW);
JCas hypothesisView = jcas.getView(LAP_ImplBase.HYPOTHESISVIEW);
Integer id = null;
String stringID = pairAnno.getPairID();
try {
id = Integer.valueOf(stringID);
}
catch (NumberFormatException e) {
// Ignore
}
RTEClassificationType gold = null;
String goldString = pairAnno.getGoldAnswer();
if (goldString != null) {
DecisionLabel goldDecision = DecisionLabel.getLabelFor(goldString);
gold = DecisionTypeMap.toRTEClassificationType(goldDecision);
}
CasTreeConverter converter = new CasTreeConverter();
List<BasicNode> textTrees = converter.convertCasToTrees(textView);
Map<BasicNode, String> mapTreesToSentences = converter.getTreesToSentences();
Sentence hypothesisSentence = JCasUtil.selectSingle(hypothesisView, Sentence.class);
BasicNode hypothesisTree = converter.convertSingleSentenceToTree(hypothesisView, hypothesisSentence);
// Currently not supporting coreference information - using empty map
TreeCoreferenceInformation<BasicNode> coreferenceInformation = new TreeCoreferenceInformation<BasicNode>();
TextHypothesisPair pair = new TextHypothesisPair(textAnno.getCoveredText(), hypothesisAnno.getCoveredText(), id, gold, null);
return new PairData(pair, textTrees, hypothesisTree, mapTreesToSentences, coreferenceInformation);
}
示例2: process
import org.uimafit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public ClassificationTEDecision process(JCas jcas)
throws EDAException, ComponentException
{
Pair pair = JCasUtil.selectSingle(jcas, Pair.class);
// Compute similarity scores with all components
List<Double> scores = new ArrayList<Double>();
for (ScoringComponent component : getComponents())
{
Vector<Double> subscores = component.calculateScores(jcas);
scores.addAll(subscores);
}
// If multiple components have been used, we use the highest score
// to determine the Entailment/NonEntailment relationship.
// This is intended for illustration purposes only, as the similarity
// scores are not normally distributed.
double maxScore = Collections.max(scores);
DecisionLabel label;
if (maxScore >= threshold)
label = DecisionLabel.Entailment;
else
label = DecisionLabel.NonEntailment;
return new ClassificationTEDecision(label,
scores.get(0),
pair.getPairID());
}
示例3: checkAnnotations
import org.uimafit.util.JCasUtil; //导入方法依赖的package包/类
private void checkAnnotations(JCas doc) {
Collection<Second> seconds = JCasUtil.select(doc, Second.class);
Second s1 = null;
Second s2 = null;
assertTrue(seconds.size() == 2);
for (Second s : seconds) {
if (s.getBegin() == 6) {
assertTrue(s.getEnd() == 10);
s1 = s;
}
if (s.getBegin() == 5) {
assertTrue(s.getEnd() == 9);
s2 = s;
}
}
DocumentAnnotation docAnnot = JCasUtil.selectSingle(
doc,
DocumentAnnotation.class);
assertTrue(docAnnot != null);
Collection<First> firsts = JCasUtil.select(doc, First.class);
assertTrue(firsts.size() == 2);
for (First f : firsts) {
if (f.getBegin() == 1) {
assertTrue(f.getEnd() == 3);
assertTrue(f.getAnnot() == s1);
assertTrue(f.getBool());
assertFalse(f.getBoolArray(0));
assertTrue(f.getBoolArray(2));
assertTrue(f.getDocAnnot() == docAnnot);
assertTrue(f.getFirst() == f);
assertTrue(f.getInteger() == 123);
assertTrue(f.getIntegerList().getNthElement(0) == 5467);
assertTrue(f.getIntegerList().getNthElement(1) == 345);
assertTrue(f.getRefToSofa() == doc.getSofa());
assertTrue(f.getSecond() == s2);
assertTrue(f.getString().equals("String value"));
}
if (f.getBegin() == 0) {
assertTrue(f.getFirst() != null);
}
}
}
示例4: getPairIdFromCas
import org.uimafit.util.JCasUtil; //导入方法依赖的package包/类
/**
* Returns the pair ID from a JCas created by an EOP LAP.
* @param jcas
* @return
*/
public static String getPairIdFromCas(JCas jcas) {
Pair pairAnno = JCasUtil.selectSingle(jcas, Pair.class);
return pairAnno.getPairID();
}