diff --git a/CHANGELOG.md b/CHANGELOG.md index 6996de2..11c5df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/wn/__main__.py b/wn/__main__.py index d797802..42c2c6f 100644 --- a/wn/__main__.py +++ b/wn/__main__.py @@ -27,8 +27,8 @@ def _projects(args): key, info['id'], info['version'], - f"[{info['language']}]", - info['label'], + f"[{info['language'] or '---'}]", + info['label'] or '---', )) ) diff --git a/wn/_config.py b/wn/_config.py index ae3fcbe..78d33c8 100644 --- a/wn/_config.py +++ b/wn/_config.py @@ -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. @@ -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. @@ -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': {}, @@ -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')), @@ -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(): diff --git a/wn/constants.py b/wn/constants.py index ee89deb..6832ebe 100644 --- a/wn/constants.py +++ b/wn/constants.py @@ -294,3 +294,8 @@ 'presupposed': 10, 'proposed': 11, } + +# resource types + +_WORDNET = 'wordnet' +_ILI = 'ili' diff --git a/wn/index.toml b/wn/index.toml index 771ecb2..7c1de0c 100644 --- a/wn/index.toml +++ b/wn/index.toml @@ -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"