def getCategoryName(self, sentenceGraph, e1, e2, directed=True):
     # Dummies are potential entities that do not exist in the 
     # training data. If both entities of an interaction are dummies
     # it can't exist in the training data and is therefore a negative
     if e1[2] or e2[2]:
         return "neg"
     
     e1 = e1[0]
     e2 = e2[0]
     
     interactions = sentenceGraph.getInteractions(e1, e2)
     if not directed:
         interactions.extend(sentenceGraph.getInteractions(e2, e1))
     
     types = set()
     for interaction in interactions:
         types.add(interaction.attrib["type"])
     types = list(types)
     types.sort()
     categoryName = ""
     for name in types:
         if categoryName != "":
             categoryName += "---"
         categoryName += name
     if categoryName != "":
         return categoryName
     else:
         return "neg"           
 def getCategoryName(self, sentence1, sentence2, e1, e2, directed=True):
     """
     Example class. Multiple overlapping edges create a merged type.
     """
     e1Id = e1.get("id")
     e2Id = e2.get("id")
     allInteractions = sentence1.interSentenceInteractions + sentence2.interSentenceInteractions
     interactions = []
     #if len(allInteractions) > 0:
     #    print len(allInteractions)
     for interaction in allInteractions:
         if interaction.get("e1") == e1Id and interaction.get("e2") == e2Id:
             interactions.append(interaction)
     types = set()
     for interaction in interactions:
         types.add(interaction.get("type"))
     types = list(types)
     types.sort()
     categoryName = ""
     for name in types:
         if categoryName != "":
             categoryName += "---"
         categoryName += name
     if categoryName != "":
         return categoryName
     else:
         return "neg"
    def getCategoryName(self, sentenceGraph, e1, e2, directed=True):
        # Dummies are potential entities that do not exist in the
        # training data. If both entities of an interaction are dummies
        # it can't exist in the training data and is therefore a negative
        if e1[2] or e2[2]:
            return "neg"

        e1 = e1[0]
        e2 = e2[0]

        interactions = sentenceGraph.getInteractions(e1, e2)
        if not directed:
            interactions.extend(sentenceGraph.getInteractions(e2, e1))

        types = set()
        for interaction in interactions:
            types.add(interaction.attrib["type"])
        types = list(types)
        types.sort()
        categoryName = ""
        for name in types:
            if categoryName != "":
                categoryName += "---"
            categoryName += name
        if categoryName != "":
            return categoryName
        else:
            return "neg"
Esempio n. 4
0
 def getMergedEntityType(self, entities):
     """
     If a single token belongs to multiple entities of different types,
     a new, composite type is defined. This type is the alphabetically
     ordered types of these entities joined with '---'.
     """
     types = set()
     for entity in entities:
         types.add(entity.get("type"))
     types = list(types)
     types.sort()
     typeString = ""
     for type in types:
         if typeString != "":
             typeString += "---"
         typeString += type
     return typeString
Esempio n. 5
0
 def getMergedEntityType(self, entities):
     """
     If a single token belongs to multiple entities of different types,
     a new, composite type is defined. This type is the alphabetically
     ordered types of these entities joined with '---'.
     """
     types = set()
     for entity in entities:
         types.add(entity.get("type"))
     types = list(types)
     types.sort()
     typeString = ""
     for type in types:
         if typeString != "":
             typeString += "---"
         typeString += type
     return typeString