Closed cdhx closed 3 years ago
@cdhx Hi, happy Dragon Boat Festival! and sorry for my late reply. This is the colab for examples in README, and they work well. I can't figure out what your question is through the given print. Could you give me more details, e.g., your pytorch/supar version, which OS did you use, and more log info.
windows10 python 3.6 pytorch '1.8.1+cpu' supar '1.0.1'
>>> con = Parser.load('crf-con-en')
C:\Users\HX\.conda\envs\py36\lib\site-packages\torch\hub.py:452: UserWarning: Falling back to the old format < 1.6. This support will be deprecated in favor of default zipfile format introduced in 1.6. Please redo torch.save() to save it in the new zipfile format.
warnings.warn('Falling back to the old format < 1.6. This support will be '
>>> con.predict(['I', 'saw', 'Sarah', 'with', 'a', 'telescope', '.'], verbose=False)[0].pretty_print()
2021-06-14 15:17:22 INFO Loading these models for language: en (English):
========================
| Processor | Package |
------------------------
| tokenize | combined |
========================
2021-06-14 15:17:22 INFO Use device: cpu
2021-06-14 15:17:22 INFO Loading: tokenize
2021-06-14 15:17:22 INFO Done loading processors!
Traceback (most recent call last):
File "<ipython-input-22-7a4348a76bbd>", line 1, in <module>
con.predict(['I', 'saw', 'Sarah', 'with', 'a', 'telescope', '.'], verbose=False)[0].pretty_print()
AttributeError: 'generator' object has no attribute 'pretty_print'
Thank you for your patience, happy Dragon Boat Festival!
Another problem, when calling predict, the 0th element of the returned result in the readme will print some information
>>> from supar import Parser
>>> parser = Parser.load('biaffine-dep-en')
>>> dataset = parser.predict('I saw Sarah with a telescope.', lang='en', prob=True, verbose=False)
>>> dataset[0]
1 I _ _ _ _ 2 nsubj _ _
2 saw _ _ _ _ 0 root _ _
3 Sarah _ _ _ _ 2 dobj _ _
4 with _ _ _ _ 2 prep _ _
5 a _ _ _ _ 6 det _ _
6 telescope _ _ _ _ 4 pobj _ _
7 . _ _ _ _ 2 punct _ _
and this is my output, return
>>> parser = Parser.load(r'biaffine-dep-en')
>>> dataset = parser.predict('I saw Sarah with a telescope.', lang='en', prob=True, verbose=False)
>>> dataset[0]
C:\Users\HX\.conda\envs\py36\lib\site-packages\torch\hub.py:452: UserWarning: Falling back to the old format < 1.6. This support will be deprecated in favor of default zipfile format introduced in 1.6. Please redo torch.save() to save it in the new zipfile format.
warnings.warn('Falling back to the old format < 1.6. This support will be '
2021-06-14 15:10:50 INFO Loading these models for language: en (English):
========================
| Processor | Package |
------------------------
| tokenize | combined |
========================
2021-06-14 15:10:50 INFO Use device: cpu
2021-06-14 15:10:50 INFO Loading: tokenize
2021-06-14 15:10:50 INFO Done loading processors!
<generator object Dataset.__getitem__ at 0x0000025123D8BF68>
Please upgrade to 1.1.1 first. Some features such as pretty_print
were recently added in 1.1.1.
So using 1.0.1 may lead to some unexpected errors.
thanks, it works
run tutorial command
got error