test.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. 'Stick element after scroll has passed the element'
  17. ]
  18. )
  19. def test_antonyms(snapshot, text):
  20. generator = Generator(text=text, strategy=leaf_no_prep_strategy, parser=JavascriptParser())
  21. results = generator.suggest()
  22. text_results = []
  23. for suggestion in results:
  24. text_results.append([token.lemma_ for token in suggestion])
  25. presented_results = generator.present()
  26. displacy.serve(generator.doc, port=5001)
  27. print(presented_results)
  28. # ADVCL
  29. # follow adverbial clauses and discard the verb