Python spacy.symbols() Examples

The following are 1 code examples of spacy.symbols(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module spacy , or try the search function .
Example #1
Source File: base_lang.py    From sumeval with Apache License 2.0 6 votes vote down vote up
def parse_to_be(self, text):
        from spacy.symbols import VERB, ADJ, NOUN
        doc = self.load_parser()(text)
        bes = []

        for token in doc:
            # chunk level dependencies
            if token.pos == NOUN and token.head.pos in [VERB, ADJ]:
                print("a.{}=({})=>{}".format(token, token.dep_, token.head))
                be = BasicElement(token.text, token.head.lemma_,
                                  token.dep_,)
                bes.append(be)
                print(be)
            elif token.pos in [VERB, ADJ] and token.head.pos == NOUN:
                print("b.{}=({})=>{}".format(token, token.dep_, token.head))
                be = BasicElement(token.head.text, token.lemma_,
                                  token.dep_,)
                bes.append(be)

        return bes