Skip to content

Commit f587a33

Browse files
authored
Merge pull request #118 from goodmami/v0.7.0
V0.7.0
2 parents 44d01d4 + 9ed1502 commit f587a33

29 files changed

+1966
-175
lines changed

CHANGELOG.md

+44
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22

33
## [Unreleased]
44

5+
## [v0.7.0]
6+
7+
**Release date: 2021-06-09**
8+
9+
### Added
10+
11+
* Support for approximate word searches; on by default, configurable
12+
only by instantiating a `wn.Wordnet` object ([#105])
13+
* `wn.morphy` ([#19])
14+
* `wn.Wordnet.lemmatizer` attribute ([#8])
15+
* `wn.web` ([#116])
16+
* `wn.Sense.relations()` ([#82])
17+
* `wn.Synset.relations()` ([#82])
18+
19+
### Changed
20+
21+
* `wn.lmf.load()` now takes a `progress_handler` parameter ([#46])
22+
* `wn.lmf.scan_lexicons()` no longer returns sets of relation types or
23+
lexfiles; `wn.add()` now gets these from loaded lexicons instead
24+
* `wn.util.ProgressHandler`
25+
- Now has a `refresh_interval` parameter; updates only trigger a
26+
refresh after the counter hits the threshold set by the interval
27+
- The `update()` method now takes a `force` parameter to trigger a
28+
refresh regardless of the refresh interval
29+
* `wn.Wordnet`
30+
- Initialization now takes a `normalizer` parameter ([#105])
31+
- Initialization now takes a `lemmatizer` parameter ([#8])
32+
- Initialization now takes a `search_all_forms` parameter ([#115])
33+
- `Wordnet.words()`, `Wordnet.senses()` and `Wordnet.synsets()` now
34+
use any specified lemmatization or normalization functions to
35+
expand queries on word forms ([#105])
36+
37+
### Fixed
38+
39+
* `wn.Synset.ili` for proposed ILIs now works again (#117)
40+
541

642
## [v0.6.2]
743

@@ -311,6 +347,7 @@ the https://github.com/nltk/wordnet/ code which had been effectively
311347
abandoned, but this is an entirely new codebase.
312348

313349

350+
[v0.7.0]: ../../releases/tag/v0.7.0
314351
[v0.6.2]: ../../releases/tag/v0.6.2
315352
[v0.6.1]: ../../releases/tag/v0.6.1
316353
[v0.6.0]: ../../releases/tag/v0.6.0
@@ -325,9 +362,12 @@ abandoned, but this is an entirely new codebase.
325362
[unreleased]: ../../tree/main
326363

327364
[#7]: https://github.com/goodmami/wn/issues/7
365+
[#8]: https://github.com/goodmami/wn/issues/8
328366
[#15]: https://github.com/goodmami/wn/issues/15
329367
[#17]: https://github.com/goodmami/wn/issues/17
368+
[#19]: https://github.com/goodmami/wn/issues/19
330369
[#23]: https://github.com/goodmami/wn/issues/23
370+
[#46]: https://github.com/goodmami/wn/issues/46
331371
[#47]: https://github.com/goodmami/wn/issues/47
332372
[#58]: https://github.com/goodmami/wn/issues/58
333373
[#59]: https://github.com/goodmami/wn/issues/59
@@ -348,6 +388,7 @@ abandoned, but this is an entirely new codebase.
348388
[#78]: https://github.com/goodmami/wn/issues/78
349389
[#79]: https://github.com/goodmami/wn/issues/79
350390
[#81]: https://github.com/goodmami/wn/issues/81
391+
[#82]: https://github.com/goodmami/wn/issues/82
351392
[#83]: https://github.com/goodmami/wn/issues/83
352393
[#86]: https://github.com/goodmami/wn/issues/86
353394
[#87]: https://github.com/goodmami/wn/issues/87
@@ -362,3 +403,6 @@ abandoned, but this is an entirely new codebase.
362403
[#105]: https://github.com/goodmami/wn/issues/105
363404
[#106]: https://github.com/goodmami/wn/issues/106
364405
[#108]: https://github.com/goodmami/wn/issues/108
406+
[#115]: https://github.com/goodmami/wn/issues/115
407+
[#116]: https://github.com/goodmami/wn/issues/116
408+
[#117]: https://github.com/goodmami/wn/issues/117

docs/api/wn.constants.rst

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ Sense Relations
140140
- ``other``
141141

142142

143+
.. _parts-of-speech:
144+
143145
Parts of Speech
144146
---------------
145147

docs/api/wn.morphy.rst

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
wn.morphy
3+
=========
4+
5+
.. automodule:: wn.morphy
6+
7+
.. seealso::
8+
9+
The Princeton WordNet `documentation
10+
<https://wordnet.princeton.edu/documentation/morphy7wn>`_ describes
11+
the original implementation of Morphy.
12+
13+
The :doc:`../guides/lemmatization` guide describes how Wn handles
14+
lemmatization in general.
15+
16+
17+
Initialized and Uninitialized Morphy
18+
------------------------------------
19+
20+
There are two ways of using Morphy in Wn: initialized and
21+
uninitialized.
22+
23+
Unintialized Morphy is a simple callable that returns lemma
24+
*candidates* for some given wordform. That is, the results might not
25+
be valid lemmas, but this is not a problem in practice because
26+
subsequent queries against the database will filter out the invalid
27+
ones. This callable is obtained by creating a :class:`Morphy` object
28+
with no arguments:
29+
30+
>>> from wn import morphy
31+
>>> m = morphy.Morphy()
32+
33+
As an uninitialized Morphy cannot predict which lemmas in the result
34+
are valid, it always returns the original form and any transformations
35+
it can find for each part of speech:
36+
37+
>>> m('lemmata', pos='n') # exceptional form
38+
{'n': {'lemmata'}}
39+
>>> m('lemmas', pos='n') # regular morphology with part-of-speech
40+
{'n': {'lemma', 'lemmas'}}
41+
>>> m('lemmas') # regular morphology for any part-of-speech
42+
{None: {'lemmas'}, 'n': {'lemma'}, 'v': {'lemma'}}
43+
>>> m('wolves') # invalid forms may be returned
44+
{None: {'wolves'}, 'n': {'wolf', 'wolve'}, 'v': {'wolve', 'wolv'}}
45+
46+
47+
This lemmatizer can also be used with a :class:`wn.Wordnet` object to
48+
expand queries:
49+
50+
>>> import wn
51+
>>> ewn = wn.Wordnet('ewn:2020')
52+
>>> ewn.words('lemmas')
53+
[]
54+
>>> ewn = wn.Wordnet('ewn:2020', lemmatizer=morphy.Morphy())
55+
>>> ewn.words('lemmas')
56+
[Word('ewn-lemma-n')]
57+
58+
An initialized Morphy is created with a :class:`wn.Wordnet` object as
59+
its argument. It then uses the wordnet to build lists of valid lemmas
60+
and exceptional forms (this takes a few seconds). Once this is done,
61+
it will only return lemmas it knows about:
62+
63+
>>> ewn = wn.Wordnet('ewn:2020')
64+
>>> m = morphy.Morphy(ewn)
65+
>>> m('lemmata', pos='n') # exceptional form
66+
{'n': {'lemma'}}
67+
>>> m('lemmas', pos='n') # regular morphology with part-of-speech
68+
{'n': {'lemma'}}
69+
>>> m('lemmas') # regular morphology for any part-of-speech
70+
{'n': {'lemma'}}
71+
>>> m('wolves') # invalid forms are pre-filtered
72+
{'n': {'wolf'}}
73+
74+
In order to use an initialized Morphy lemmatizer with a
75+
:class:`wn.Wordnet` object, it must be assigned to the object after
76+
creation:
77+
78+
>>> ewn = wn.Wordnet('ewn:2020') # default: lemmatizer=None
79+
>>> ewn.words('lemmas')
80+
[]
81+
>>> ewn.lemmatizer = morphy.Morphy(ewn)
82+
>>> ewn.words('lemmas')
83+
[Word('ewn-lemma-n')]
84+
85+
There is little to no difference in the results obtained from a
86+
:class:`wn.Wordnet` object using an initialized or uninitialized
87+
:class:`Morphy` object, but there may be slightly different
88+
performance profiles for future queries.
89+
90+
91+
Default Morphy Lemmatizer
92+
-------------------------
93+
94+
As a convenience, an uninitialized Morphy lemmatizer is provided in
95+
this module via the :data:`morphy` member.
96+
97+
.. data:: morphy
98+
99+
A :class:`Morphy` object created without a :class:`wn.Wordnet`
100+
object.
101+
102+
103+
The Morphy Class
104+
----------------
105+
106+
.. autoclass:: Morphy

docs/api/wn.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ Wn's data storage and retrieval can be configured through the
286286

287287
.. seealso::
288288

289-
:doc:`../guides/setup` describes how to configure Wn using the
289+
:doc:`../setup` describes how to configure Wn using the
290290
:data:`wn.config` instance.
291291

292292
.. autodata:: config

0 commit comments

Comments
 (0)