test.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import json
  2. import pytest
  3. from word_processor.parsers import JavascriptParser
  4. from word_processor.strategies.leaf_no_preps_strategy import leaf_no_prep_strategy
  5. from word_processor.generators import Generator
  6. from spacy import displacy
  7. @pytest.mark.parametrize(
  8. 'text',
  9. [
  10. # 'Regex for redacted phone numbers with extra info for PlayStation',
  11. # 'Two days ago i was shocked by a red pair of trousers',
  12. 'Setting priority for attempting hydration',
  13. # 'Attempting to set hydration priority',
  14. # 'file Cache Provider get Cache Dir',
  15. #'Setters Value Animator Animator Update Listener'
  16. ]
  17. )
  18. def test_antonyms(snapshot, text):
  19. generator = Generator(text=text, strategy=leaf_no_prep_strategy, parser=JavascriptParser())
  20. results = generator.suggest()
  21. text_results = []
  22. for suggestion in results:
  23. text_results.append([token.lemma_ for token in suggestion])
  24. presented_results = generator.present()
  25. # displacy.serve(generator.doc, port=5001)
  26. print(presented_results)