A simple extension for spaCy to leverage WordNet, one of the richest knowledge databases in the world. Use your favorite NLP tool together with a powerful dictionary.

I want to withdraw 100 euros

take out
draw off


      import spacy
      from spacy_wordnet.wordnet_annotator import WordnetAnnotator
      # Load an spacy model (supported models are "es" and "en")
      nlp = spacy.load('en')
      nlp.add_pipe(WordnetAnnotator(nlp.lang), after='tagger')
      token = nlp('prices')[0]

      # wordnet object link spacy token with nltk wordnet interface by giving acces to

      # And automatically tags with wordnet domains

      # spaCy WordNet lets you find synonyms by domain of interest for example economy
      sentence = nlp('I want to withdraw 5,000 euros')
      economy_domains = ['finance', 'banking']

      token_with_synsets = [(token, token._.wordnet.wordnet_synsets_for_domain(economy_domains)) for token in sentence]
      enriched_sentence = []
      for token, synsets in token_with_synsets:
          if not synsets:
              lemmas_for_synset = {lemma for s in synsets for lemma in s.lemma_names()}
      print(' '.join(enriched_sentence))
      # >> I (need|want|require) to (draw|withdraw|draw_off|take_out) 5,000 euros

Recognai is an artificial intelligence software company who help teams and data scientists to cope with information overload.

We enable companies to convert unstructured data and text into accessible and valuable information, as a prerequisite for high-quality digital processes. We do this by providing easy access to cutting-edge technology in natural language processing and machine learning.

  • ree
  • airbus-group_1
  • atresmedia
  • dzbank
  • reale
  • uniserv