Skip to content

Commit

Permalink
Merge pull request #8 from aeye-lab/fix-parse-dependency
Browse files Browse the repository at this point in the history
fix parse dependency
  • Loading branch information
SiQube authored Jun 15, 2022
2 parents 91d776c + c5f558b commit d1e248c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions utils/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,22 @@ def parse_dependency(text) -> Tuple[
nlp.vocab, token_match=re.compile(r'\S+').match,
)
doc = nlp(text)
n_rights: List[List[int]] = [[] for _ in range(len(text.split()))]
n_lefts: List[List[int]] = [[] for _ in range(len(text.split()))]
rights: List[List[str]] = [[] for _ in range(len(text.split()))]
lefts: List[List[str]] = [[] for _ in range(len(text.split()))]
deps: List[List[int]] = [[] for _ in range(len(text.split()))]
n_rights = [[] for _ in range(len(text.split()))]
n_lefts = [[] for _ in range(len(text.split()))]
rights = [[] for _ in range(len(text.split()))]
lefts = [[] for _ in range(len(text.split()))]
deps = [[] for _ in range(len(text.split()))]
dep_distance = [[] for _ in range(len(text.split()))]

for idx, token in enumerate(doc):
deps[idx] = token.dep_
rights[idx] = list(token.rights)
lefts[idx] = list(token.lefts)
n_rights[idx] = token.n_rights
n_lefts[idx] = token.n_lefts
return deps, n_rights, rights, n_lefts, lefts
dep_distance[idx] = token.i - token.head.i

return deps, n_rights, rights, n_lefts, lefts, dep_distance


# create counts for entities
Expand Down

0 comments on commit d1e248c

Please sign in to comment.