use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class MultilingualEreReaderTest method testReader.
private static void testReader(EREEventReader reader) {
assertTrue(reader.hasNext());
XmlTextAnnotation xmlTa = reader.next();
TextAnnotation ta = xmlTa.getTextAnnotation();
assertTrue(ta.hasView(ViewNames.MENTION_ERE));
assertTrue(ta.getView(ViewNames.MENTION_ERE).getConstituents().size() > 5);
assertTrue(ta.getView(ViewNames.MENTION_ERE).getRelations().size() > 0);
assertTrue(ta.hasView(ViewNames.EVENT_ERE));
assertTrue(ta.getView(ViewNames.EVENT_ERE).getConstituents().size() > 1);
assertTrue(ta.getView(ViewNames.EVENT_ERE).getRelations().size() > 2);
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class StanfordCorefHandler method addView.
@Override
protected void addView(TextAnnotation ta) throws AnnotatorException {
Annotation document = new Annotation(ta.text);
pipeline.annotate(document);
CoreferenceView vu = new CoreferenceView(viewName, ta);
Map corefChain = document.get(CorefCoreAnnotations.CorefChainAnnotation.class);
for (Object key : corefChain.keySet()) {
CorefChain chain = (CorefChain) corefChain.get(key);
Constituent representative = createConstituentGivenMention(document, chain, chain.getRepresentativeMention(), ta);
List<Constituent> consList = new ArrayList<>();
for (CorefChain.CorefMention m : chain.getMentionsInTextualOrder()) {
consList.add(createConstituentGivenMention(document, chain, m, ta));
}
// remove the representative itself
consList.remove(representative);
vu.addCorefEdges(representative, consList);
}
ta.addView(viewName, vu);
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class CreateTestFeaturesResource method addFeatCollection.
private void addFeatCollection() throws EdisonException, IOException {
Map<Integer, String> map = new HashMap<>();
FeatureCollection featureCollection = new FeatureCollection("features");
featureCollection.addFeatureExtractor(WordFeatureExtractorFactory.conflatedPOS);
featureCollection.addFeatureExtractor(WordFeatureExtractorFactory.gerundMarker);
featureCollection.addFeatureExtractor(WordFeatureExtractorFactory.nominalizationMarker);
for (TextAnnotation ta : tas) {
for (int tokenId = 0; tokenId < ta.size(); tokenId++) {
Constituent c = new Constituent("", "", ta, tokenId, tokenId + 1);
Set<Feature> features = featureCollection.getFeatures(c);
if (features.size() > 0) {
String id = ta.getTokenizedText() + ":" + tokenId;
map.put(id.hashCode(), features.toString());
}
}
}
IOUtils.writeObject(map, FEATURE_COLLECTION_FILE);
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class CreateTestFeaturesResource method addBrownFeatures.
private void addBrownFeatures() throws EdisonException {
logger.info("\tadding Brown cluster features");
WordFeatureExtractor brownFeatureGenerator = WordFeatureExtractorFactory.getBrownFeatureGenerator("", "brownBllipClusters", new int[] { 4, 5 });
for (TextAnnotation ta : tas) {
addFeatures(ta, brownFeatureGenerator);
}
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class CreateTestFeaturesResource method addWordNet.
private void addWordNet() throws EdisonException {
logger.info("\tadding wordNet");
WordNetManager.loadConfigAsClasspathResource(true);
for (TextAnnotation ta : tas) {
addFeatures(ta, WordFeatureExtractorFactory.getWordNetFeatureExtractor(WordNetFeatureExtractor.WordNetFeatureClass.existsEntry, WordNetFeatureExtractor.WordNetFeatureClass.synsetsFirstSense, WordNetFeatureExtractor.WordNetFeatureClass.lexicographerFileNamesAllSenses));
}
}
Aggregations