def buildAuxiliaryFrame(self, verb): frame = SCF() frame.verb = verb.lemma frame.position = verb.id verbElement = Element(sintax = 'AUX', element = 'AUX', relevance = 0, position = verb.id, raw = verb.word) frame.elements.append(verbElement) return frame
def extract(self, sentence): palavrasSentence = self.buildSentence(sentence) #sentence.html = palavrasSentence.toHTML() verbs = palavrasSentence.getVerbs() frames = [] for verb in verbs: frame = SCF() isVerbSer = False verbWord = verb.word if verb.isAuxialiary(): verbCore, verbWord = palavrasSentence.searchCoreVerb(verb) if not verbCore: continue frames.append(self.buildAuxiliaryFrame(verb)) verb = verbCore[len(verbCore)-1] for verbSer in verbCore: if verbSer.lemma == 'ser' and verb.father and verb.father.id == verbSer.id: isVerbSer = True if isVerbSer and len(verb.morphos) > 1 and 'PCP' in verb.morphos: frame.isPassive = True verb.coreVerb = verbCore verb.hasAuxiliary = True # insert verb on the frame frame.verb = verb.lemma frame.position = verb.id verbElement = Element(sintax = 'V', element = 'V', relevance = 0, position = verb.id, raw = verbWord) frame.elements.append(verbElement) hasSubject = False # build frame on main verb dependencies for child in verb.children: element = self.buildElement(child) if element: if element.sintax == 'SUBJ': hasSubject = True frame.elements.append(element) # if sentence has a auxiliary verb needs a correction to point SUBJ to main verb if verb.hasAuxiliary: core = verb.coreVerb auxiliary = palavrasSentence.tokens[core[0].id] for child in auxiliary.children: if "SUBJ" == child.function: element = self.buildElement(child) if element: frame.elements.append(element) hasSubject = True # frame has not subject, create a hidden subject if not hasSubject: token = Token() token.word = 'HIDDEN' token.lemma = 'HIDDEN' token.function = 'SUBJ' element = self.buildElement(token) if element: frame.elements.append(element) frames.append(frame) return frames