Skip to content

Commit

Permalink
flake8 fixes 🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
asajatovic committed Jun 13, 2021
1 parent 425b178 commit 5e078bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion spacy_udpipe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
from .utils import download, load, load_from_path
from .tokenizer import UDPipeTokenizer
from .udpipe import UDPipeModel

4 changes: 3 additions & 1 deletion spacy_udpipe/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def tokenizer_factory(

return tokenizer_factory


def _spacy_dep(d: str) -> str:
# Ensure labels match with SpaCy
return d.upper() if d == "root" else d


class UDPipeTokenizer(object):
"""Custom Tokenizer which sets all the attributes because
the UDPipe pipeline runs only once and does not
Expand Down Expand Up @@ -200,4 +202,4 @@ def to_bytes(self, **kwargs):
return b""

def from_bytes(self, _bytes_data, **kwargs):
return self
return self
5 changes: 3 additions & 2 deletions spacy_udpipe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ def load(
"""
config = {"nlp": {"tokenizer": {}}}
name = lang.split("-")[0]
config["nlp"]["tokenizer"]["@tokenizers"] = "spacy_udpipe.PipelineAsTokenizer.v1"
config["nlp"]["tokenizer"]["@tokenizers"] = "spacy_udpipe.PipelineAsTokenizer.v1" # noqa: E501
# Set UDPipe options
config["nlp"]["tokenizer"]["lang"] = lang
config["nlp"]["tokenizer"]["path"] = get_path(lang)
config["nlp"]["tokenizer"]["meta"] = None
return blank(name, config=config)


def load_from_path(
lang: str,
path: str,
Expand All @@ -110,7 +111,7 @@ def load_from_path(
"""
config = {"nlp": {"tokenizer": {}}}
name = lang.split("-")[0]
config["nlp"]["tokenizer"]["@tokenizers"] = "spacy_udpipe.PipelineAsTokenizer.v1"
config["nlp"]["tokenizer"]["@tokenizers"] = "spacy_udpipe.PipelineAsTokenizer.v1" # noqa: E501
# Set UDPipe options
config["nlp"]["tokenizer"]["lang"] = lang
config["nlp"]["tokenizer"]["path"] = path
Expand Down
4 changes: 2 additions & 2 deletions tests/test_spacy_udpipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def test_ro_morph() -> None:
text = "Ce mai faci?"

download(lang=lang)

nlp = load(lang=lang)
doc = nlp(text)

assert doc.to_json()

0 comments on commit 5e078bd

Please sign in to comment.