Issue
I tried to work with OpenKiwi to Anaconda3 and after installation (pip install openkiwi) I execute following code (I do this because I want to create openkiwi vocabulary) :
import warnings
from collections import defaultdict
import torchtext
from kiwi.constants import PAD, START, STOP, UNALIGNED, UNK, UNK_ID
And than I have an error message:
ImportError Traceback (most recent call last)
<ipython-input-6-ea850b280bef> in <module>
4 import torchtext
5
----> 6 from kiwi.constants import PAD, START, STOP, UNALIGNED, UNK, UNK_ID
ImportError: cannot import name 'UNK_ID' from 'kiwi.constants' (C:\Users\Mike\anaconda3\lib\site-packages\kiwi\constants.py)
Anaconda3 has following versions: >!
- pytorch-lightning: 1.7.6
- pytorch-nlp: 0.5.0
- torch: 1.4.0
- torch metrics 0.9.3
- torch: text 0.13.1
- transformers: 3.5.1
Solution
UNK_ID
is no longer a constant in the latest version of OpenKiwi. That second link shows some code targeting version 1.4 or so, while OpenKiwi is at version 2.1 now. Just drop the UNK_ID
from the import
line, and replace the one in the code with 0
.
Answered By - JHBonarius
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.