mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-13 21:26:58 +03:00
5ca7dd0f94
* Improve load_language_data helper * WIP: Add Lookups implementation * Start moving lemma data over to JSON * WIP: move data over for more languages * Convert more languages * Fix lemmatizer fixtures in tests * Finish conversion * Auto-format JSON files * Fix test for now * Make sure tables are stored on instance
27 lines
754 B
Python
27 lines
754 B
Python
# coding: utf-8
|
|
from __future__ import unicode_literals
|
|
|
|
import pytest
|
|
from spacy.lookups import Lookups
|
|
|
|
|
|
def test_lookups_api():
|
|
table_name = "test"
|
|
data = {"foo": "bar", "hello": "world"}
|
|
lookups = Lookups()
|
|
lookups.add_table(table_name, data)
|
|
assert table_name in lookups
|
|
assert lookups.has_table(table_name)
|
|
table = lookups.get_table(table_name)
|
|
assert table.name == table_name
|
|
assert len(table) == 2
|
|
assert table.get("hello") == "world"
|
|
table.set("a", "b")
|
|
assert table.get("a") == "b"
|
|
table = lookups.get_table(table_name)
|
|
assert len(table) == 3
|
|
with pytest.raises(KeyError):
|
|
lookups.get_table("xyz")
|
|
# with pytest.raises(ValueError):
|
|
# lookups.add_table(table_name)
|