Skip to content

Commit f1a3ef7

Browse files
committed
Fix type errors
1 parent b1265cc commit f1a3ef7

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

ttc/language/russian/pipelines/actor_classifier.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ def has_noun_or_propn(span: Span) -> bool:
9797
def is_pronoun_vague(token: Token) -> bool:
9898
if token.pos != PRON:
9999
return False
100-
if token.morph.get("Person"):
100+
if token.morph.get("Person", []):
101101
return False
102-
pron_types = set(token.morph.get("PronType"))
102+
pron_types = set(token.morph.get("PronType", []))
103103
if "Prs" in pron_types:
104104
return False
105105
return True if pron_types or token.pos == PRON else False
@@ -153,16 +153,16 @@ def is_nominative(token: Token) -> bool:
153153

154154

155155
def is_oblique(token: Token) -> bool:
156-
cases = token.morph.get("Case")
156+
cases = token.morph.get("Case", [])
157157
return bool(cases) and "Nom" not in cases
158158

159159

160160
def has_first_person(span: Span) -> bool:
161-
return any("First" in t.morph.get("Person") for t in span if t.is_alpha)
161+
return any("First" in t.morph.get("Person", []) for t in span if t.is_alpha)
162162

163163

164164
def has_second_person(span: Span) -> bool:
165-
return any("Second" in t.morph.get("Person") for t in span if t.is_alpha)
165+
return any("Second" in t.morph.get("Person", []) for t in span if t.is_alpha)
166166

167167

168168
def has_specific_role(span: Span) -> bool:
@@ -235,7 +235,7 @@ def is_vague_actor(span: Optional[Span]) -> bool:
235235
if not span:
236236
return False
237237
if span.root.pos == ADJ and not has_noun_or_propn(span):
238-
return bool(span.root.morph.get("PronType") or span.root.morph.get("NumType"))
238+
return bool(span.root.morph.get("PronType", []) or span.root.morph.get("NumType", []))
239239
return is_vague_head(span)
240240

241241

@@ -275,7 +275,7 @@ def is_human_like(span: Optional[Span]) -> bool:
275275
return True
276276
if any(t.pos == PROPN and ANIMACY_ANIM in t.morph for t in span):
277277
return True
278-
return any(t.pos == PRON and t.morph.get("Person") for t in span)
278+
return any(t.pos == PRON and t.morph.get("Person", []) for t in span)
279279

280280

281281
def has_voice_intro(replica: Span) -> bool:
@@ -420,7 +420,7 @@ def morph_aligns_with(target: Token) -> Callable[[Token], bool]:
420420
def aligned_gender(tk) -> Optional[str]:
421421
t = noun_chunk(tk)
422422
if len(t) == 1:
423-
return [*t.root.morph.get(Gender), None][0] # type: ignore
423+
return [*t.root.morph.get(Gender, []), None][0] # type: ignore
424424
morphs: Dict[str, str] = next(
425425
(
426426
v
@@ -430,7 +430,7 @@ def aligned_gender(tk) -> Optional[str]:
430430
),
431431
{},
432432
)
433-
stats = Counter([*tk.morph.get(Gender), None][0] for tk in t) # type: ignore
433+
stats = Counter([*tk.morph.get(Gender, []), None][0] for tk in t) # type: ignore
434434
return morphs.get(Gender, max(stats, key=stats.get)) # type: ignore
435435

436436
target_gender = aligned_gender(target)
@@ -852,7 +852,7 @@ def exact_enough(n):
852852
if resolve_refs:
853853
m_refs = [] if (has_strong_non_ref and not ref) else list(filter(is_ref, matching))
854854
m_verbs = list(filter(ref_matcher, root_verbs))
855-
person = m_refs[0].morph.get("Person") if m_refs else []
855+
person = m_refs[0].morph.get("Person", []) if m_refs else []
856856
if (
857857
not ref
858858
and len(m_refs) == 1
@@ -1144,6 +1144,7 @@ def classify_actors(
11441144
if (
11451145
actor
11461146
and prev_actor
1147+
and p_replica
11471148
and has_first_person(replica)
11481149
and has_second_person(p_replica)
11491150
and prev_penult
@@ -1200,6 +1201,7 @@ def classify_actors(
12001201
if (
12011202
actor
12021203
and prev_actor
1204+
and p_replica
12031205
and has_first_person(replica)
12041206
and has_second_person(p_replica)
12051207
and prev_penult

ttc/language/russian/pipelines/replicizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def is_author_annotation(match: Span) -> bool:
8989
if any(
9090
p in ("First", "Second")
9191
for t in alpha_tokens
92-
for p in t.morph.get("Person")
92+
for p in t.morph.get("Person", [])
9393
):
9494
return False
9595

@@ -313,7 +313,7 @@ def extend_interrogative_tail(replica: Span) -> Span:
313313
break
314314
if has_newline(token):
315315
break
316-
if "Second" in token.morph.get("Person"):
316+
if "Second" in token.morph.get("Person", []):
317317
has_second_person = True
318318
if token.text in {"?", "!"}:
319319
has_question = True

0 commit comments

Comments
 (0)