public static List<TextAnnotation> getTAs(List<String> scope){ List<TextAnnotation> tas = new ArrayList<>(); if (scope.contains("ACE")) { ACEReader aceReader = null; try { aceReader = new ACEReader("data/all", false); } catch (Exception e) { e.printStackTrace(); } for (TextAnnotation ta : aceReader) { tas.add(ta); } } if (scope.contains("ERE")) { EREMentionRelationReader ereMentionRelationReader = null; try { ereMentionRelationReader = new EREMentionRelationReader(EREDocumentReader.EreCorpus.ENR3, "data/ere/data", false); } catch (Exception e) { e.printStackTrace(); } for (XmlTextAnnotation xta : ereMentionRelationReader) { tas.add(xta.getTextAnnotation()); } } return tas; } public Object next(){
public static List<TextAnnotation> getTAs(List<String> scope){ List<TextAnnotation> tas = new ArrayList<>(); if (scope.contains("ACE")) { ACEReader aceReader = null; try { aceReader = new ACEReader("data/all", false); } catch (Exception e) { e.printStackTrace(); } for (TextAnnotation ta : aceReader) { tas.add(ta); } } if (scope.contains("ERE")) { EREMentionRelationReader ereMentionRelationReader = null; try { ereMentionRelationReader = new EREMentionRelationReader(EREDocumentReader.EreCorpus.ENR3, "data/ere/data", false); } catch (Exception e) { e.printStackTrace(); } for (XmlTextAnnotation xta : ereMentionRelationReader) { tas.add(xta.getTextAnnotation()); } } return tas; } public Object next(){
public static List<TextAnnotation> getTAs(List<String> scope){ List<TextAnnotation> tas = new ArrayList<>(); if (scope.contains("ACE")) { ACEReader aceReader = null; try { aceReader = new ACEReader("data/all", false); } catch (Exception e) { e.printStackTrace(); } for (TextAnnotation ta : aceReader) { tas.add(ta); } } if (scope.contains("ERE")) { EREMentionRelationReader ereMentionRelationReader = null; try { ereMentionRelationReader = new EREMentionRelationReader(EREDocumentReader.EreCorpus.ENR3, "data/ere/data", false); } catch (Exception e) { e.printStackTrace(); } for (XmlTextAnnotation xta : ereMentionRelationReader) { tas.add(xta.getTextAnnotation()); } } return tas; } public Object next(){
ret.add(xta.getTextAnnotation());
ret.add(xta.getTextAnnotation());
private Constituent createTrigger(Node eventMentionNode, XmlTextAnnotation xmlTa, String eventId) throws XMLException { /* <trigger source="ENG_DF_001241_20150407_F0000007T" offset="179" length="5">trade</trigger> */ NodeList nl = ((Element) eventMentionNode).getElementsByTagName(TRIGGER); Constituent trigger = null; if (nl.getLength() == 0) throw new IllegalStateException("Event " + eventId + " has no trigger element."); if (nl.getLength() > 1) throw new IllegalStateException("Event " + eventId + " has multiple trigger elements."); for (int i = 0; i < nl.getLength(); ++i) { Node eventTriggerNode = nl.item(i); String triggerForm = SimpleXMLParser.getContentString((Element) eventTriggerNode); NamedNodeMap nnMap = eventTriggerNode.getAttributes(); String source = nnMap.getNamedItem(SOURCE).getNodeValue(); int offset = Integer.parseInt(nnMap.getNamedItem(OFFSET).getNodeValue()); int length = Integer.parseInt(nnMap.getNamedItem(LENGTH).getNodeValue()); IntPair offsets = getTokenOffsets(offset, offset + length, triggerForm, xmlTa); if (null == offsets) return null; else if (-1 == offsets.getFirst() && -1 == offsets.getSecond()) { // offsets correspond to deleted span return null; // handled by next layer up, which records the info separately } trigger = new Constituent(TRIGGER, getEventViewName(), xmlTa.getTextAnnotation(), offsets.getFirst(), offsets.getSecond() + 1); trigger.addAttribute(EventIdAttribute, eventId); trigger.addAttribute(SOURCE, source); } return trigger; }
private Constituent createTrigger(Node eventMentionNode, XmlTextAnnotation xmlTa, String eventId) throws XMLException { /* <trigger source="ENG_DF_001241_20150407_F0000007T" offset="179" length="5">trade</trigger> */ NodeList nl = ((Element) eventMentionNode).getElementsByTagName(TRIGGER); Constituent trigger = null; if (nl.getLength() == 0) throw new IllegalStateException("Event " + eventId + " has no trigger element."); if (nl.getLength() > 1) throw new IllegalStateException("Event " + eventId + " has multiple trigger elements."); for (int i = 0; i < nl.getLength(); ++i) { Node eventTriggerNode = nl.item(i); String triggerForm = SimpleXMLParser.getContentString((Element) eventTriggerNode); NamedNodeMap nnMap = eventTriggerNode.getAttributes(); String source = nnMap.getNamedItem(SOURCE).getNodeValue(); int offset = Integer.parseInt(nnMap.getNamedItem(OFFSET).getNodeValue()); int length = Integer.parseInt(nnMap.getNamedItem(LENGTH).getNodeValue()); IntPair offsets = getTokenOffsets(offset, offset + length, triggerForm, xmlTa); if (null == offsets) return null; else if (-1 == offsets.getFirst() && -1 == offsets.getSecond()) { // offsets correspond to deleted span return null; // handled by next layer up, which records the info separately } trigger = new Constituent(TRIGGER, getEventViewName(), xmlTa.getTextAnnotation(), offsets.getFirst(), offsets.getSecond() + 1); trigger.addAttribute(EventIdAttribute, eventId); trigger.addAttribute(SOURCE, source); } return trigger; }
XmlDocumentProcessor.compileOffsetSpanMapping(sourceTa.getXmlMarkup()); TextAnnotation ta = sourceTa.getTextAnnotation(); SpanLabelView tokens = (SpanLabelView) ta.getView(ViewNames.TOKENS); compileOffsets(tokens); sourceTa.getTextAnnotation().addView(getMentionViewName(), nerView); AnnotationFixer.rationalizeBoundaryAnnotations(sourceTa.getTextAnnotation(), getCorefViewName()); } else AnnotationFixer.rationalizeBoundaryAnnotations(sourceTa.getTextAnnotation(), getCorefViewName());
ereMentionRelationReader = new EREMentionRelationReader(EREDocumentReader.EreCorpus.ENR3, _path, false); for (XmlTextAnnotation xta : ereMentionRelationReader){ TextAnnotation ta = xta.getTextAnnotation(); ta.addView(posAnnotator); ret.add(ta);
@Override public List<XmlTextAnnotation> getAnnotationsFromFile(List<Path> corpusFileListEntry) throws Exception { XmlTextAnnotation xmlTa = super.getAnnotationsFromFile(corpusFileListEntry).get(0); TextAnnotation sourceTa = xmlTa.getTextAnnotation(); // SpanLabelView tokens = (SpanLabelView)sourceTa.getView(ViewNames.TOKENS); View mentionView = sourceTa.getView(getMentionViewName()); if (null == mentionView) throw new IllegalStateException("View '" + getMentionViewName() + "' (mention view) not found."); // now pull all mentions we deal with for (int i = 1; i < corpusFileListEntry.size(); ++i) { Document doc = SimpleXMLParser.getDocument(corpusFileListEntry.get(i).toFile()); // super.getEntitiesFromFile(doc, mentionView, xmlTa); // super.getFillersFromFile(doc, mentionView, xmlTa); /* * previous call populates mentionID : Constituent map needed to build relations * efficiently */ getRelationsFromFile(doc, mentionView); } sourceTa.addView(getMentionViewName(), mentionView); return Collections.singletonList(xmlTa); }
@Override public List<XmlTextAnnotation> getAnnotationsFromFile(List<Path> corpusFileListEntry) throws Exception { XmlTextAnnotation xmlTa = super.getAnnotationsFromFile(corpusFileListEntry).get(0); TextAnnotation sourceTa = xmlTa.getTextAnnotation(); // SpanLabelView tokens = (SpanLabelView)sourceTa.getView(ViewNames.TOKENS); View mentionView = sourceTa.getView(getMentionViewName()); if (null == mentionView) throw new IllegalStateException("View '" + getMentionViewName() + "' (mention view) not found."); // now pull all mentions we deal with for (int i = 1; i < corpusFileListEntry.size(); ++i) { Document doc = SimpleXMLParser.getDocument(corpusFileListEntry.get(i).toFile()); // super.getEntitiesFromFile(doc, mentionView, xmlTa); // super.getFillersFromFile(doc, mentionView, xmlTa); /* * previous call populates mentionID : Constituent map needed to build relations * efficiently */ getRelationsFromFile(doc, mentionView); } sourceTa.addView(getMentionViewName(), mentionView); return Collections.singletonList(xmlTa); }
@Override public List<XmlTextAnnotation> getAnnotationsFromFile(List<Path> corpusFileListEntry) throws Exception { XmlTextAnnotation xmlTa = super.getAnnotationsFromFile(corpusFileListEntry).get(0); TextAnnotation sourceTa = xmlTa.getTextAnnotation(); // SpanLabelView tokens = (SpanLabelView)sourceTa.getView(ViewNames.TOKENS); View mentionView = sourceTa.getView(getMentionViewName()); if (null == mentionView) throw new IllegalStateException("View '" + getMentionViewName() + "' (mention view) not found."); PredicateArgumentView eventView = new PredicateArgumentView(getEventViewName(), NAME, sourceTa, 1.0); // process one or more files containing stand-off annotations for (int i = 1; i < corpusFileListEntry.size(); ++i) { Document doc = SimpleXMLParser.getDocument(corpusFileListEntry.get(i).toFile()); getEventsFromFile(doc, eventView, xmlTa); } sourceTa.addView(getEventViewName(), eventView); return Collections.singletonList(xmlTa); }
@Override public List<XmlTextAnnotation> getAnnotationsFromFile(List<Path> corpusFileListEntry) throws Exception { XmlTextAnnotation xmlTa = super.getAnnotationsFromFile(corpusFileListEntry).get(0); TextAnnotation sourceTa = xmlTa.getTextAnnotation(); // SpanLabelView tokens = (SpanLabelView)sourceTa.getView(ViewNames.TOKENS); View mentionView = sourceTa.getView(getMentionViewName()); if (null == mentionView) throw new IllegalStateException("View '" + getMentionViewName() + "' (mention view) not found."); PredicateArgumentView eventView = new PredicateArgumentView(getEventViewName(), NAME, sourceTa, 1.0); // process one or more files containing stand-off annotations for (int i = 1; i < corpusFileListEntry.size(); ++i) { Document doc = SimpleXMLParser.getDocument(corpusFileListEntry.get(i).toFile()); getEventsFromFile(doc, eventView, xmlTa); } sourceTa.addView(getEventViewName(), eventView); return Collections.singletonList(xmlTa); }
XmlDocumentProcessor.compileOffsetSpanMapping(sourceTa.getXmlMarkup()); TextAnnotation ta = sourceTa.getTextAnnotation(); SpanLabelView tokens = (SpanLabelView) ta.getView(ViewNames.TOKENS); compileOffsets(tokens); sourceTa.getTextAnnotation().addView(getMentionViewName(), nerView); AnnotationFixer.rationalizeBoundaryAnnotations(sourceTa.getTextAnnotation(), getCorefViewName()); } else AnnotationFixer.rationalizeBoundaryAnnotations(sourceTa.getTextAnnotation(), getCorefViewName());
private void addCorefView(XmlTextAnnotation xmlTa) { TextAnnotation ta = xmlTa.getTextAnnotation(); CoreferenceView cView = new CoreferenceView(getCorefViewName(), ta); for (String eId : entityIdToMentionIds.keySet()) {
private void addCorefView(XmlTextAnnotation xmlTa) { TextAnnotation ta = xmlTa.getTextAnnotation(); CoreferenceView cView = new CoreferenceView(getCorefViewName(), ta); for (String eId : entityIdToMentionIds.keySet()) {
TextAnnotation ta = xmlTa.getTextAnnotation(); View nerView = ta.getView(reader.getMentionViewName()); CoNLL2002Writer.writeViewInCoNLL2003Format(nerView, ta,
TextAnnotation ta = xmlTa.getTextAnnotation(); View nerView = ta.getView(reader.getMentionViewName()); CoNLL2002Writer.writeViewInCoNLL2003Format(nerView, ta,
TextAnnotation ta = xta.getTextAnnotation(); List<SpanInfo> fudge = xta.getXmlMarkup();
TextAnnotation ta = xta.getTextAnnotation(); List<SpanInfo> fudge = xta.getXmlMarkup();