Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run_stanza.py - AttributeError: type object 'CoNLL' has no attribute 'convert_dict' #6

Closed
iiegn opened this issue Jan 22, 2024 · 1 comment

Comments

@iiegn
Copy link
Contributor

iiegn commented Jan 22, 2024

stanza deprecated convert_dict() and (at least in 1.7.0) it's not supported anymore. Hence, run_stanza.py fails with:

Traceback (most recent call last):
  File "/tmp/stanza/./run_stanza.py", line 41, in <module>
    main()
  File "/tmp/stanza/./run_stanza.py", line 33, in main
    conll = CoNLL.convert_dict(dicts)
AttributeError: type object 'CoNLL' has no attribute 'convert_dict'

which seemingly can be fixed with:

diff --git a/utils/run_stanza.py b/utils/run_stanza.py
index 02318ff..1508ac5 100755
--- a/utils/run_stanza.py
+++ b/utils/run_stanza.py
@@ -29,12 +29,7 @@ def main():
         filename = os.path.basename(fh.name)
         text = fh.read()
         doc = nlp(text)
-        dicts = doc.to_dict()
-        conll = CoNLL.convert_dict(dicts)
-        with open(os.path.join(args.output_dir, filename + ".conllu"), mode="w", encoding="utf-8") as out:
-            for sentence in conll:
-                out.write("\n".join(("\t".join(token) for token in sentence)))
-                out.write("\n\n")
+        CoNLL.write_doc2conll(doc, os.path.join(args.output_dir, filename + ".conllu"))
@tsproisl
Copy link
Owner

Thanks for noticing and providing a patch!

@iiegn iiegn closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants