leaf_no_preps_strategy.py 566 B

1234567891011121314151617181920212223
  1. from .leaf_strategy import leaf_strategy
  2. def leaf_no_prep_strategy(doc):
  3. """
  4. Should return an arrays of variable names based on leaf strategy without the preps(at, for)
  5. :param doc: spacy document
  6. :return Array of strings
  7. """
  8. suggestions = leaf_strategy(doc)
  9. new_suggestions = []
  10. for suggestion in suggestions:
  11. new_suggestion = []
  12. for token in suggestion:
  13. if token.dep_ != 'prep':
  14. new_suggestion.append(token)
  15. new_suggestions.append(new_suggestion)
  16. return new_suggestions