Skip to content

Commit

Permalink
Add support for typed index entries; CILI entry
Browse files Browse the repository at this point in the history
Part of #23
  • Loading branch information
goodmami committed Feb 10, 2021
1 parent 86cc46c commit 646f0c3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
* `wn.Form.tags()` ([#65])
* `wn.Count` ([#65])
* `wn.Sense.counts()` ([#65])
* Index entries of different types; default is `'wordnet'`, `'ili'` is
also available ([#23])
* A CILI index entry ([#23])

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions wn/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def _projects(args):
key,
info['id'],
info['version'],
f"[{info['language']}]",
info['label'],
f"[{info['language'] or '---'}]",
info['label'] or '---',
))
)

Expand Down
19 changes: 12 additions & 7 deletions wn/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from wn import Error
from wn._types import AnyPath
from wn.constants import _WORDNET
from wn._util import is_url, resources, short_hash

# The directory where downloaded and added data will be stored.
Expand Down Expand Up @@ -58,11 +59,12 @@ def index(self) -> Dict[str, Dict]:
return self._projects

def add_project(
self,
id: str,
label: str,
language: str,
license: str = None,
self,
id: str,
type: str = _WORDNET,
label: str = None,
language: str = None,
license: str = None,
) -> None:
"""Add a new wordnet project to the index.
Expand All @@ -77,6 +79,7 @@ def add_project(
if id in self._projects:
raise ValueError(f'project already added: {id}')
self._projects[id] = {
'type': type,
'label': label,
'language': language,
'versions': {},
Expand Down Expand Up @@ -137,6 +140,7 @@ def get_project_info(self, arg: str) -> Dict:
return dict(
id=id,
version=version,
type=project['type'],
label=project['label'],
language=project['language'],
license=versions[version].get('license', project.get('license')),
Expand Down Expand Up @@ -180,8 +184,9 @@ def update(self, data: dict) -> None:
else:
self.add_project(
id,
project['label'],
project['language'],
type=project.get('type', _WORDNET),
label=project.get('label'),
language=project.get('language'),
license=project.get('license'),
)
for version, info in project.get('versions', {}).items():
Expand Down
5 changes: 5 additions & 0 deletions wn/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,8 @@
'presupposed': 10,
'proposed': 11,
}

# resource types

_WORDNET = 'wordnet'
_ILI = 'ili'
7 changes: 7 additions & 0 deletions wn/index.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[cili]
type = "ili"
label = "Collaborative Interlingual Index"
license = "https://creativecommons.org/licenses/by/4.0/"
[cili.versions."1.0"]
url = "https://github.com/globalwordnet/cili/releases/download/v1.0/cili.tsv.xz"

[ewn]
label = "Open English WordNet"
language = "en"
Expand Down

0 comments on commit 646f0c3

Please sign in to comment.