Search in sources :

Example 1 with AceCharSeq

use of edu.stanford.nlp.ie.machinereading.domains.ace.reader.AceCharSeq in project CoreNLP by stanfordnlp.

the class AceReader method convertAceEventMention.

private EventMention convertAceEventMention(AceEventMention aceEventMention, String docId, CoreMap sentence, Map<String, EntityMention> entityMap, int tokenOffset) {
    Set<String> roleSet = aceEventMention.getRoles();
    List<String> roles = new ArrayList<>();
    for (String role : roleSet) roles.add(role);
    List<ExtractionObject> convertedArgs = new ArrayList<>();
    int left = Integer.MAX_VALUE;
    int right = Integer.MIN_VALUE;
    for (String role : roles) {
        AceEntityMention arg = aceEventMention.getArg(role);
        ExtractionObject o = entityMap.get(arg.getId());
        if (o == null) {
            logger.severe("READER ERROR: Failed to find event argument with id " + arg.getId());
            logger.severe("This happens because a few event mentions illegally span multiple sentences. Will ignore this mention.");
            return null;
        }
        convertedArgs.add(o);
        if (o.getExtentTokenStart() < left)
            left = o.getExtentTokenStart();
        if (o.getExtentTokenEnd() > right)
            right = o.getExtentTokenEnd();
    }
    AceCharSeq anchor = aceEventMention.getAnchor();
    ExtractionObject anchorObject = new ExtractionObject(aceEventMention.getId() + "-anchor", sentence, new Span(anchor.getTokenStart() - tokenOffset, anchor.getTokenEnd() + 1 - tokenOffset), "ANCHOR", null);
    EventMention em = new EventMention(aceEventMention.getId(), sentence, new Span(left, right), aceEventMention.getParent().getType(), aceEventMention.getParent().getSubtype(), anchorObject, convertedArgs, roles);
    return em;
}
Also used : EventMention(edu.stanford.nlp.ie.machinereading.structure.EventMention) AceEventMention(edu.stanford.nlp.ie.machinereading.domains.ace.reader.AceEventMention) ExtractionObject(edu.stanford.nlp.ie.machinereading.structure.ExtractionObject) ArrayList(java.util.ArrayList) AceEntityMention(edu.stanford.nlp.ie.machinereading.domains.ace.reader.AceEntityMention) Span(edu.stanford.nlp.ie.machinereading.structure.Span) AceCharSeq(edu.stanford.nlp.ie.machinereading.domains.ace.reader.AceCharSeq)

Aggregations

AceCharSeq (edu.stanford.nlp.ie.machinereading.domains.ace.reader.AceCharSeq)1 AceEntityMention (edu.stanford.nlp.ie.machinereading.domains.ace.reader.AceEntityMention)1 AceEventMention (edu.stanford.nlp.ie.machinereading.domains.ace.reader.AceEventMention)1 EventMention (edu.stanford.nlp.ie.machinereading.structure.EventMention)1 ExtractionObject (edu.stanford.nlp.ie.machinereading.structure.ExtractionObject)1 Span (edu.stanford.nlp.ie.machinereading.structure.Span)1 ArrayList (java.util.ArrayList)1