Exemple #1
0
 def Tag(self,sentence):
     sentenceLength = sentence.getSentenceLength()
     modalityDetector = ModalityDetector()
     polarityDetector = PolarityDetector()
     eventAttributes = []#EventAttributes()
     
     for wordIndex in range(sentenceLength):
         if sentence.getPOSCoarse(wordIndex) == 'N':
             word = sentence.getWord(wordIndex)
             classfeature = 'STATE'
             pos = 'NOUN'#sentence.getPOSCoarse(wordIndex)
             aspect = sentence.getAspectuality(wordIndex)
             modality = modalityDetector.Detect(sentence, wordIndex)
             polarity = polarityDetector.detect(word, pos, sentence.getLemma(wordIndex))
             tense = sentence.getTense(wordIndex)
             mood = sentence.getMood(wordIndex)
             
             if self.compoundVerb.IsPartOfCompoundVerb(sentence,wordIndex):
                 self.eventAttribute = self.eventAttribute.SetAttributes(isEvent=False,text=word)
                 eventAttributes.append(self.eventAttribute)
                 continue
             if sentence.getPOSFine(wordIndex) == 'ANM':
                 self.eventAttribute = self.eventAttribute.SetAttributes(isEvent=False,text=word)
                 eventAttributes.append(self.eventAttribute)
                 continue
             if self.compoundNoun.IsPartOfCompoundNoun(sentence, wordIndex):
                 eventAttribute = self.eventAttribute.SetAttributes(True,globals.id,globals.eventID,classfeature,word,aspect,modality,pos,polarity,tense,mood)
                 eventAttributes.append(eventAttribute)
                 globals.eventID+=1
                 globals.id+=1
                 continue
             if self.IsCausativeInContext(sentence,wordIndex):
                 eventAttribute = self.eventAttribute.SetAttributes(True,globals.id,globals.eventID,classfeature,word,aspect,modality,pos,polarity,tense,mood)
                 eventAttributes.append(eventAttribute)
                 globals.eventID+=1
                 globals.id+=1
                 continue
             if self.IsAspectual(sentence,wordIndex):
                 eventAttribute = self.eventAttribute.SetAttributes(True,globals.id,globals.eventID,classfeature,word,aspect,modality,pos,polarity,tense,mood)
                 eventAttributes.append(eventAttribute)
                 globals.eventID+=1
                 globals.id+=1
                 continue
             if self.IsAspectualInContext(sentence,wordIndex):
                 eventAttribute = self.eventAttribute.SetAttributes(True,globals.id,globals.eventID,classfeature,word,aspect,modality,pos,polarity,tense,mood)
                 eventAttributes.append(eventAttribute)
                 globals.eventID+=1
                 globals.id+=1
                 continue
             
             eventAttribute = self.eventAttribute.SetAttributes(isEvent=False)
             eventAttributes.append(eventAttribute)
         else:
             eventAttribute = self.eventAttribute.SetAttributes(isEvent=False,text=sentence.getWord(wordIndex))
             eventAttributes.append(eventAttribute)
     return eventAttributes
Exemple #2
0
 def Tag(self, sentence):
     sentenceLength = sentence.getSentenceLength()
     eventAttributes = []#EventAttributes()
     modalityDetector = ModalityDetector()
     classFeatureExtractor = ClassFeatureExtraction()
     polarityDetector = PolarityDetector()
     global eventID
     for wordIndex in range(sentenceLength):
         #word = sentence.getWord(wordIndex)
         #print(word)
         if sentence.getPOSCoarse(wordIndex) == 'V':
             word = sentence.getWord(wordIndex)
             aspect = sentence.getAspectuality(wordIndex)
             modality = modalityDetector.Detect(sentence, wordIndex)
             pos = 'VERB'
             polarity = polarityDetector.detect(word, sentence.getPOSCoarse(wordIndex), sentence.getLemma(wordIndex))
             tense = sentence.getTense(wordIndex)
             mood = sentence.getMood(wordIndex)
             
             if self.IsAstBoodHast(sentence,wordIndex):
                 self.eventAttribute = self.eventAttribute.SetAttributes(isEvent=False,text=sentence.getWord(wordIndex))
                 eventAttributes.append(self.eventAttribute)
                 continue
             if self.IsProgressive(sentence,wordIndex):
                 self.eventAttribute = self.eventAttribute.SetAttributes(isEvent=False,text=sentence.getWord(wordIndex))
                 eventAttributes.append(self.eventAttribute)
                 continue
             if self.IsModal(sentence,wordIndex):
                 self.eventAttribute = self.eventAttribute.SetAttributes(isEvent=False,text=sentence.getWord(wordIndex))
                 eventAttributes.append(self.eventAttribute)
                 continue
             
             
             #s3 In this scenario we already have compound verb with consecutive parts as one single token we tagged them with one eventID and for other verbs just the verb part tagged
                 
             '''
             #s2 In this scenario compound verbs detected and the verbs with consecutive parts tagged with the same eventID and others just the verb part tagged
             if self.IsCompoundVerb(sentence, wordIndex):
                 
                 verbIdices = self.compoundVerb.extractNonVerbalIndexOfCompoundVerb(sentence, wordIndex)
                 verbWord = ''
                 for index in verbIdices:
                     verbWord += sentence.getWord(index)+' '
                 verbWord += sentence.getWord(wordIndex)
                 classfeature = classFeatureExtractor.Extract(verbWord)
                 
                 verbIdices.append(wordIndex)
                 if self.IsConsecutive(verbIdices):
                     verbWord=''
                     for index in verbIdices:
                         verbWord += sentence.getWord(index)+' '
                     polarity = polarityDetector.detect(verbWord, sentence.getPOSCoarse(wordIndex),sentence.getLemma(wordIndex))
                     eventAttribute = self.eventAttribute.SetAttributes(True,globals.eventID,classfeature,verbWord,aspect,modality,pos,polarity,tense,mood)
                 else:
                     eventAttribute = self.eventAttribute.SetAttributes(True,globals.eventID,classfeature,word,aspect,modality,pos,polarity,tense,mood)
                 '''
             #s1 In this scenario all the parts tagged with the same eventID
             if self.IsCompoundVerb(sentence, wordIndex):
                 verbIdices = self.compoundVerb.extractNonVerbalIndexOfCompoundVerb(sentence, wordIndex)
                 verbWord = ''
                 for index in verbIdices:
                     verbWord += sentence.getWord(index)+' '
                 verbWord = verbWord.rstrip(' ')
                 verbWord = verbWord + ' ' + word
                 classfeature = classFeatureExtractor.Extract(verbWord)
                 for index in verbIdices:
                     #verbWord += sentence.getWord(wordIndex)+' '
                     eventAttribute = self.eventAttribute.SetAttributes(True,globals.id,globals.eventID,classfeature,sentence.getWord(index),aspect,modality,pos,polarity,tense,mood)
                     eventAttributes[index] = eventAttribute
                     globals.id+=1
                 eventAttribute = self.eventAttribute.SetAttributes(True,globals.id,globals.eventID,classfeature,word,aspect,modality,pos,polarity,tense,mood)
                 eventAttributes.append(eventAttribute)
                 globals.eventID +=1
                 globals.id+=1
             else:
                 classfeature = classFeatureExtractor.Extract(word)
                 eventAttribute = self.eventAttribute.SetAttributes(True,globals.id,globals.eventID,classfeature,word,aspect,modality,pos,polarity,tense,mood)
                 eventAttributes.append(eventAttribute)
                 globals.eventID +=1
                 globals.id+=1
         else:
             eventAttribute = self.eventAttribute.SetAttributes(isEvent=False,text=sentence.getWord(wordIndex))
             eventAttributes.append(eventAttribute)
     return eventAttributes