Commit b9efd80
synset pos parameter (#15)
* modified: spacy_wordnet/wordnet_domains.py
- importing Synset class and added return type hint to __find_synsets(...) method
- pep8 character limit adjustment
* modified: spacy_wordnet/wordnet_domains.py
- added optional pos param to __find_synsets(...) method
* modified: spacy_wordnet/wordnet_domains.py
- argument handling for pos param
* modified: spacy_wordnet/wordnet_domains.py
- swapping all(map(...)) for set(...).difference(...) which gives a slight boost in speed and readability
* modified: spacy_wordnet/wordnet_domains.py
- added try/except to attempt to convert pos arg to list
* modified: spacy_wordnet/wordnet_domains.py
- filtering acceptable_pos using pos values and assigning to token_pos which will be used to determine which tokens to get synsets for
* modified: spacy_wordnet/wordnet_domains.py
- moved call from self.__synsets declaration into .synsets(...) method allowing user to supply pos args
* modified: spacy_wordnet/wordnet_domains.py
- return type hint and docstring for synsets(...) method
* modified: tests/test_wordnet_annotator.py
- added three assertions for pos param in test_english_annotations() method
* modified: spacy_wordnet/wordnet_domains.py
- fixed error type hint in synsets(...) method
* modified: spacy_wordnet/wordnet_domains.py
- fixed type error in __find_lemmas() method by swapping self.__synsets attribute with self.synsets(...) method
- pep8 character limit fix in __find_lemmas() method
* modified: spacy_wordnet/wordnet_domains.py
- defined token_synsets as a separate list and filtered returned synsets in wn.synsets and extending token_synsets in __find_synsets(...) method
* modified: tests/test_wordnet_annotator.py
changed expected_adj_synsets to set() instead of {} (a dict) in test_english_annotations() method
* Update spacy_wordnet/wordnet_domains.py
param type hint spacing/formatting in synsets(...) method
Co-authored-by: Francisco Aranda <francisco@recogn.ai>
* Update spacy_wordnet/wordnet_domains.py
param type hint spacing/formatting in __find_synsets(...) method
Co-authored-by: Francisco Aranda <francisco@recogn.ai>
* use token.pos if pos argument is none to mimic previous behavior.
Co-authored-by: Francisco Aranda <francisco@recogn.ai>
* Update wordnet_domains.py
modified docstring to reflect what happens if pos argument is none
* modified: tests/test_wordnet_annotator.py
- added assert to test that list of pos args will return expected results
* modified: tests/test_wordnet_annotator.py
- added test for when pos argument is none
* Update spacy_wordnet/wordnet_domains.py
Checking if `token.pos` is an acceptable value before appending its lemma to the `word_variants` list. This avoids unexpected results such as when `token.pos` is an `ADVERB`.
Co-authored-by: Francisco Aranda <francisco@recogn.ai>
* Update wordnet_domains.py
Updated docstring so user knows results are limited to NOUN, VERB, and ADJ even if `pos` is None.
Co-authored-by: Ian Thompson <ian.thompson@hrblock.com>
Co-authored-by: Francisco Aranda <francisco@recogn.ai>1 parent 4bc9fe0 commit b9efd80
File tree
2 files changed
+94
-14
lines changed- spacy_wordnet
- tests
2 files changed
+94
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | | - | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
50 | 67 | | |
51 | 68 | | |
52 | 69 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | 70 | | |
57 | 71 | | |
58 | 72 | | |
| |||
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
71 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
72 | 107 | | |
73 | | - | |
| 108 | + | |
74 | 109 | | |
75 | 110 | | |
76 | 111 | | |
77 | 112 | | |
78 | | - | |
79 | | - | |
80 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
81 | 119 | | |
82 | 120 | | |
83 | 121 | | |
| |||
95 | 133 | | |
96 | 134 | | |
97 | 135 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 136 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
31 | 77 | | |
32 | 78 | | |
33 | 79 | | |
| |||
0 commit comments