Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
oroszgy committed Aug 24, 2017
1 parent ce24c36 commit 41c0cf2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
29 changes: 19 additions & 10 deletions src/main/python/hunlp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@


class Token:
def __init__(self, arcLabel: str, entityType: str, headId: int, id: int, lemma: str, pos: str, tagProperties: dict,
def __init__(self,
arcLabel: str,
entityType: str,
headId: int,
id: int,
lemma: str,
pos: str,
tagProperties: dict,
text: str):
self.i = id
self.text = text
Expand All @@ -17,7 +24,8 @@ def __str__(self):
return self.text

def __repr__(self):
return "Token({})".format(", ".join(["{}={}".format(k, str(v)) for k, v in self.__dict__.items()]))
return "Token({})".format(", ".join(
["{}={}".format(k, str(v)) for k, v in self.__dict__.items()]))


class Sentence:
Expand All @@ -34,7 +42,8 @@ def __str__(self):
return " ".join(str(tok) for tok in self._tokens)

def __repr__(self):
return "Sentence({})".format(", ".join(repr(tok) for tok in self._tokens))
return "Sentence({})".format(
", ".join(repr(tok) for tok in self._tokens))


class Doc:
Expand All @@ -51,7 +60,8 @@ def __str__(self):
return " ".join(str(s) for s in self._sentences)

def __repr__(self):
return "Doc(\n\t{}\n)".format("\n\t".join(repr(s) for s in self._sentences))
return "Doc(\n\t{}\n)".format(
"\n\t".join(repr(s) for s in self._sentences))

@property
def entities(self):
Expand All @@ -77,10 +87,9 @@ def __init__(self, host="http://localhost:9090", endpoint="v1/annotate"):
self._url = "{}/{}".format(host, endpoint)

def __call__(self, text):
result = requests.post(self._url, json={
"text": text
})
result = requests.post(self._url, json={"text": text})
data = result.json()
return Doc([Sentence([Token(**t) for t in sent["tokens"]]) for sent in data["sentences"]])


return Doc([
Sentence([Token(**t) for t in sent["tokens"]])
for sent in data["sentences"]
])
4 changes: 2 additions & 2 deletions src/main/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='hunlp',
version='0.2.0',
version='0.3.0',
description='HuNlp Python wrapper',
url='https://github.com/oroszgy/hunlp',
author='Gyorgy Orosz',
Expand All @@ -18,6 +18,6 @@
'Programming Language :: Python :: 3.5',
],
keywords='nlp hungarian entities magyarlanc pos-tagging dependency-parsing',
packages=find_packges(exclude=['contrib', 'docs', 'tests']),
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
install_requires=["requests", "plac"],
)

0 comments on commit 41c0cf2

Please sign in to comment.