modules/NLP.py
def collapse_noun_phrases_by_punctation(self):
        '''
        this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences
        :param sentence:
        :return:
        '''
        prev_span = ''
        open_brackets = u'( { [ <'.split()
        closed_brackets = u') } ] >'.split()
        for token in self.sentence:
            try:
                if token.text in open_brackets and token.whitespace_ == u'':
                    next_token = token.nbor(1)
                    if any([i in next_token.text for i in closed_brackets]):
                        span = Span(self.doc, token.i, next_token.i + 1)
                        # prev_span = span.text
                        yield span
                elif any([i in token.text for i in open_brackets]):
                    next_token = token.nbor(1)
                    if next_token.text in closed_brackets:
                        span = Span(self.doc, token.i, next_token.i + 1)
                        # prev_span = span.text
                        yield span

            except IndexError:  # skip end of sentence
                pass

        this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences
        :param sentence:
        :return:
        
this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences
this collapse needs tobe used on a single sentence otherwise it will ocncatenate different sentences
def collapse_noun_phrases_by_punctation(self):
        prev_span = ''
        open_brackets = u'( { [ <'.split()
        closed_brackets = u') } ] >'.split()
        for token in self.sentence:
            try:
                if token.text in open_brackets and token.whitespace_ == u'':
                    next_token = token.nbor(1)
                    if any([i in next_token.text for i in closed_brackets]):
                        span = Span(self.doc, token.i, next_token.i + 1)
                        yield span
                elif any([i in token.text for i in open_brackets]):
                    next_token = token.nbor(1)
                    if next_token.text in closed_brackets:
                        span = Span(self.doc, token.i, next_token.i + 1)
                        yield span
            except IndexError:  
                pass
def collapse_noun_phrases_by_punctation ( self ) : prev_span = '' open_brackets = u'( { [ <' . split ( ) closed_brackets = u') } ] >' . split ( ) for token in self . sentence : try : if token . text in open_brackets and token . whitespace_ == u'' : next_token = token . nbor ( 1 ) if any ( [ i in next_token . text for i in closed_brackets ] ) : span = Span ( self . doc , token . i , next_token . i + 1 ) yield span elif any ( [ i in token . text for i in open_brackets ] ) : next_token = token . nbor ( 1 ) if next_token . text in closed_brackets : span = Span ( self . doc , token . i , next_token . i + 1 ) yield span except IndexError : pass
this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences
this collapse needs tobe used on a single sentence otherwise it will ocncatenate different sentences
'''
        this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences
        :param sentence:
        :return:
        ''' # prev_span = span.text # prev_span = span.text # skip end of sentence
None
self
sentence
None