def newToken(currentDoc, pos): if pos == 'JJ': #logger.debug("\nFOUND ADJ token") return AdjectiveToken(currentDoc, pos) else: #logger.debug("\nFOUND normal token") return Token(currentDoc, pos)
def _process_opening_lex(self, element): """Creates a Token or AdjectviveToken and adds it to the current timex if there is one, otherwise to the current chunk if there is one, and otherwise to the current sentence if there is one.""" logger.debug(' opening lex') pos = element.attrs[POS] if pos.startswith(POS_ADJ): self.currentToken = AdjectiveToken(self.doc, pos) else: self.currentToken = Token(self.doc, pos) # this is needed for later when tokens and events are swapped, # the default is that a token does not contain an event, this # can be changed when an event tag is processed self.currentToken.contains_event = False self.currentToken.lex_tag = element logger.debug(' current chunk ' + str(self.currentChunk)) logger.debug(' current sent ' + str(self.currentSentence)) # previously, just checked the truth of self.currentChunk and # self.currentSentence, which worked fine for the latter but # not for the former (no idea why that was the case, MV) if self.currentTimex is not None: logger.debug(' adding token to chunk') self.currentTimex.add(self.currentToken) elif self.currentChunk is not None: logger.debug(' adding token to chunk') self.currentChunk.addToken(self.currentToken) elif self.currentSentence is not None: logger.debug(' adding token to sentence') self.currentSentence.add(self.currentToken)
def newToken(currentDoc, pos, markedEvent=None, lemma=None): if pos[0:2] == 'JJ': return AdjectiveToken(currentDoc, pos) else: newToken = Token(currentDoc, pos) if not markedEvent is None: newToken.markedEvent = markedEvent if not lemma is None: newToken.lemma = lemma return newToken