Skip to content

Commit 0f0b1a9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 985fc23 commit 0f0b1a9

28 files changed

+57
-61
lines changed

examples/apply_jumanpp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/apply_jumanpp.py "今日はいい天気ですね。"
55
"""
6+
67
import sys
78

89
from rhoknp import Jumanpp

examples/apply_knp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/apply_knp.py "今日はいい天気ですね。"
55
"""
6+
67
import sys
78

89
from rhoknp import KNP

examples/apply_kwja.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/apply_kwja.py "今日はいい天気ですね。"
55
"""
6+
67
import sys
78

89
from rhoknp import KWJA

examples/load_jumanpp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/load_jumanpp.py example.jumanpp
55
"""
6+
67
import sys
78

89
from rhoknp import Sentence

examples/load_knp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/load_knp.py example.jumanpp
55
"""
6+
67
import sys
78

89
from rhoknp import Sentence

examples/use_coreference_resolution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/use_coreference_resolution.py "ソビエト連邦はソ連ともよばれる。同国の首都はモスクワである。"
55
"""
6+
67
import sys
78
from typing import List
89

examples/use_dependency_parsing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/use_dependency_parsing.py "今日はいい天気ですね。"
55
"""
6+
67
import sys
78

89
from rhoknp import KNP

examples/use_discourse_relation_analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/use_discourse_relation_analysis.py "風が吹いたら桶屋が儲かる。"
55
"""
6+
67
import sys
78

89
from rhoknp import KNP

examples/use_morphological_analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/use_morphological_analysis.py "今日はいい天気ですね。"
55
"""
6+
67
import sys
78

89
from rhoknp import Jumanpp

examples/use_named_entity_recognition.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/use_named_entity_recognition.py "太郎は花子が読んでいる本を次郎に渡した。"
55
"""
6+
67
import sys
78

89
from rhoknp import KNP

examples/use_predicate_argument_structure_analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Usage:
44
$ python examples/use_predicate_argument_structure_analysis.py "太郎は花子が読んでいる本を次郎に渡した。"
55
"""
6+
67
import sys
78
from typing import Dict, List
89

src/rhoknp/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
__version__ = version("rhoknp")
77

88
__all__ = [
9-
"__version__",
10-
"RegexSenter",
11-
"Jumanpp",
129
"KNP",
1310
"KWJA",
14-
"Document",
15-
"Sentence",
16-
"Clause",
17-
"Phrase",
1811
"BasePhrase",
12+
"Clause",
13+
"Document",
14+
"Jumanpp",
1915
"Morpheme",
16+
"Phrase",
17+
"RegexSenter",
18+
"Sentence",
19+
"__version__",
2020
]

src/rhoknp/cohesion/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
from rhoknp.cohesion.rel import RelMode, RelTag, RelTagList
88

99
__all__ = [
10-
"Pas",
11-
"Predicate",
1210
"Argument",
11+
"ArgumentType",
12+
"DiscourseRelation",
13+
"DiscourseRelationLabel",
14+
"DiscourseRelationTag",
1315
"EndophoraArgument",
16+
"Entity",
17+
"EntityManager",
1418
"ExophoraArgument",
15-
"ArgumentType",
1619
"ExophoraReferent",
1720
"ExophoraReferentType",
18-
"Entity",
19-
"EntityManager",
21+
"Pas",
22+
"Predicate",
23+
"RelMode",
2024
"RelTag",
2125
"RelTagList",
22-
"RelMode",
23-
"DiscourseRelation",
24-
"DiscourseRelationLabel",
25-
"DiscourseRelationTag",
2626
]

src/rhoknp/cohesion/argument.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, case: str, arg_type: ArgumentType) -> None:
4141
self.case: str = case #: 述語に対する格.
4242
self.type: ArgumentType = arg_type #: 項のタイプ.
4343
self.optional: bool = False #: 修飾的な項かどうか.
44-
self._pas: Optional["Pas"] = None
44+
self._pas: Optional[Pas] = None
4545

4646
@abstractmethod
4747
def __str__(self) -> str:

src/rhoknp/cohesion/coreference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class Entity:
2121
def __init__(self, eid: int, exophora_referent: Optional[ExophoraReferent] = None) -> None:
2222
self.eid = eid #: エンティティ ID.
2323
self.exophora_referent = exophora_referent #: 外界照応の照応先.対応するものがなければ None.
24-
self.mentions: List["BasePhrase"] = [] #: このエンティティを参照するメンションのリスト.
25-
self.mentions_nonidentical: List["BasePhrase"] = [] #: このエンティティを≒関係で参照するメンションのリスト.
24+
self.mentions: List[BasePhrase] = [] #: このエンティティを参照するメンションのリスト.
25+
self.mentions_nonidentical: List[BasePhrase] = [] #: このエンティティを≒関係で参照するメンションのリスト.
2626

2727
@property
2828
def mentions_all(self) -> List["BasePhrase"]:

src/rhoknp/cohesion/discourse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def from_discourse_relation_fstring(cls, fstring: str, modifier: "Clause") -> Op
229229
return None
230230
tag = DiscourseRelationTag(tag)
231231
category = tag.label
232-
head_sentence: Optional["Sentence"] = None
232+
head_sentence: Optional[Sentence] = None
233233
if modifier.sentence.has_document():
234234
sentences = modifier.document.sentences
235235
else:

src/rhoknp/cohesion/predicate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class Predicate:
1818
"""
1919

2020
def __init__(self, base_phrase: "BasePhrase", cfid: Optional[str] = None) -> None:
21-
self.base_phrase: "BasePhrase" = base_phrase #: 述語の核となる基本句.
21+
self.base_phrase: BasePhrase = base_phrase #: 述語の核となる基本句.
2222
self.cfid: Optional[str] = cfid #: 格フーレムID.
23-
self._pas: Optional["Pas"] = None
23+
self._pas: Optional[Pas] = None
2424

2525
@property
2626
def text(self) -> str:

src/rhoknp/processors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from rhoknp.processors.kwja import KWJA
44
from rhoknp.processors.senter import RegexSenter
55

6-
__all__ = ["RegexSenter", "Jumanpp", "KNP", "KWJA"]
6+
__all__ = ["KNP", "KWJA", "Jumanpp", "RegexSenter"]

src/rhoknp/processors/processor.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ class Processor(ABC):
88
"""解析器の基底クラス."""
99

1010
@overload
11-
def __call__(self, text: str, timeout: int = 10) -> Document:
12-
...
11+
def __call__(self, text: str, timeout: int = 10) -> Document: ...
1312

1413
@overload
15-
def __call__(self, text: Sentence, timeout: int = 10) -> Sentence:
16-
...
14+
def __call__(self, text: Sentence, timeout: int = 10) -> Sentence: ...
1715

1816
@overload
19-
def __call__(self, text: Document, timeout: int = 10) -> Document:
20-
...
17+
def __call__(self, text: Document, timeout: int = 10) -> Document: ...
2118

2219
def __call__(self, text: Union[str, Sentence, Document], timeout: int = 10) -> Union[Document, Sentence]:
2320
"""テキストに解析器を適用する.
@@ -38,16 +35,13 @@ def __call__(self, text: Union[str, Sentence, Document], timeout: int = 10) -> U
3835
return self.apply(text, timeout=timeout)
3936

4037
@overload
41-
def apply(self, text: str, timeout: int = 10) -> Document:
42-
...
38+
def apply(self, text: str, timeout: int = 10) -> Document: ...
4339

4440
@overload
45-
def apply(self, text: Sentence, timeout: int = 10) -> Sentence:
46-
...
41+
def apply(self, text: Sentence, timeout: int = 10) -> Sentence: ...
4742

4843
@overload
49-
def apply(self, text: Document, timeout: int = 10) -> Document:
50-
...
44+
def apply(self, text: Document, timeout: int = 10) -> Document: ...
5145

5246
def apply(self, text: Union[str, Sentence, Document], timeout: int = 10) -> Union[Document, Sentence]:
5347
"""テキストに解析器を適用する.

src/rhoknp/props/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
__all__ = [
88
"DepType",
99
"FeatureDict",
10-
"SemanticsDict",
10+
"MemoTag",
1111
"NamedEntity",
1212
"NamedEntityCategory",
13-
"MemoTag",
13+
"SemanticsDict",
1414
]

src/rhoknp/units/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
from rhoknp.units.phrase import Phrase
66
from rhoknp.units.sentence import Sentence
77

8-
__all__ = ["Document", "Sentence", "Clause", "Phrase", "BasePhrase", "Morpheme"]
8+
__all__ = ["BasePhrase", "Clause", "Document", "Morpheme", "Phrase", "Sentence"]

src/rhoknp/units/base_phrase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
super().__init__()
5151

5252
# parent unit
53-
self._phrase: Optional["Phrase"] = None
53+
self._phrase: Optional[Phrase] = None
5454

5555
# child units
5656
self._morphemes: Optional[List[Morpheme]] = None
@@ -291,7 +291,7 @@ def get_coreferents(self, include_nonidentical: bool = False, include_self: bool
291291
Returns:
292292
共参照している基本句の集合.
293293
"""
294-
mentions: List["BasePhrase"] = [self]
294+
mentions: List[BasePhrase] = [self]
295295
for mention in itertools.chain.from_iterable(entity.mentions for entity in self.entities):
296296
if mention not in mentions:
297297
mentions.append(mention)

src/rhoknp/units/clause.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self) -> None:
2929
super().__init__()
3030

3131
# parent unit
32-
self._sentence: Optional["Sentence"] = None
32+
self._sentence: Optional[Sentence] = None
3333

3434
# child units
3535
self._phrases: Optional[List[Phrase]] = None

src/rhoknp/units/morpheme.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ def __init__(
9797
self.conjform_id = conjform_id #: 活用形ID.
9898

9999
# parent unit
100-
self._base_phrase: Optional["BasePhrase"] = None
101-
self._sentence: Optional["Sentence"] = None
100+
self._base_phrase: Optional[BasePhrase] = None
101+
self._sentence: Optional[Sentence] = None
102102

103103
self.semantics: SemanticsDict = (
104104
semantics if semantics is not None else SemanticsDict()
105105
) #: 辞書に記載の意味情報.
106106
self.features: FeatureDict = features if features is not None else FeatureDict() #: 素性.
107-
self.homographs: List["Morpheme"] = [] #: 同形の形態素のリスト.
107+
self.homographs: List[Morpheme] = [] #: 同形の形態素のリスト.
108108

109109
self.index = self.count #: 文内におけるインデックス.
110110
if homograph is False:
@@ -341,16 +341,7 @@ def to_knp(self) -> str:
341341
ret = self._to_jumanpp_line()
342342
features = FeatureDict(self.features) # deep copy
343343
for homograph in self.homographs:
344-
alt_feature_key = "ALT-{}-{}-{}-{}-{}-{}-{}-{}".format(
345-
homograph.surf,
346-
homograph.reading,
347-
homograph.lemma,
348-
homograph.pos_id,
349-
homograph.subpos_id,
350-
homograph.conjtype_id,
351-
homograph.conjform_id,
352-
homograph.semantics.to_sstring(),
353-
)
344+
alt_feature_key = f"ALT-{homograph.surf}-{homograph.reading}-{homograph.lemma}-{homograph.pos_id}-{homograph.subpos_id}-{homograph.conjtype_id}-{homograph.conjform_id}-{homograph.semantics.to_sstring()}"
354345
features[alt_feature_key] = True
355346
if features:
356347
ret += f" {features.to_fstring()}"

src/rhoknp/units/phrase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def __init__(
3434
super().__init__()
3535

3636
# parent unit
37-
self._clause: Optional["Clause"] = None
38-
self._sentence: Optional["Sentence"] = None
37+
self._clause: Optional[Clause] = None
38+
self._sentence: Optional[Sentence] = None
3939

4040
# child units
4141
self._base_phrases: Optional[List[BasePhrase]] = None

src/rhoknp/units/sentence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, text: Optional[str] = None) -> None:
4747
EntityManager.reset()
4848

4949
# parent unit
50-
self._document: Optional["Document"] = None
50+
self._document: Optional[Document] = None
5151

5252
# child units
5353
self._clauses: Optional[List[Clause]] = None

tests/cli/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_cat() -> None:
5151
assert result.exit_code == 0
5252

5353

54-
@pytest.fixture()
54+
@pytest.fixture
5555
def _mock_stdin(monkeypatch: pytest.MonkeyPatch) -> None:
5656
monkeypatch.setattr("sys.stdin", knp_text)
5757

tests/cli/test_serve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
@pytest.mark.skipif(not is_jumanpp_available, reason="Juman++ is not available")
16-
@pytest.fixture()
16+
@pytest.fixture
1717
def jumanpp_client() -> TestClient:
1818
app = create_app(AnalyzerType.JUMANPP)
1919
return TestClient(app)
@@ -50,7 +50,7 @@ def test_index_jumanpp(jumanpp_client: TestClient, text: str) -> None:
5050

5151

5252
@pytest.mark.skipif(not is_knp_available, reason="KNP is not available")
53-
@pytest.fixture()
53+
@pytest.fixture
5454
def knp_client() -> TestClient:
5555
app = create_app(AnalyzerType.KNP)
5656
return TestClient(app)
@@ -104,7 +104,7 @@ def test_index_knp_error(knp_client: TestClient) -> None:
104104

105105

106106
@pytest.mark.skipif(not is_kwja_available, reason="KWJA is not available")
107-
@pytest.fixture()
107+
@pytest.fixture
108108
def kwja_client() -> TestClient:
109109
app = create_app(AnalyzerType.KWJA, options=["--model-size", "tiny", "--tasks", "char,word"])
110110
return TestClient(app)

0 commit comments

Comments
 (0)