You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before the recent merge of #2860, wordnet.get_version() would fail whenever a read had already occurred from the data.adj file:
import nltk
from nltk.corpus import wordnet as wn
print(wn.get_version())
3.0
print(wn.synset_from_pos_and_offset('a',1740))
Synset('able.a.01')
print(wn.get_version())
None
The cause of the problem is that synset_from_pos_and_offset goes to a given offset in a data file, reads a line, and stays there. This function is called all the time by other functions in the wordnet module. For ex., in wordnet.doctest, synset_from_pos_and_offset is called indirectly over 10,000 times.
But now that get_version ensures that reading the data.adj starts at byte offset 0, it probably doesn't matter anywhere else, because there may not be another function that needs to read from the beginning of the data file.
It might be safer to add data_file.seek(0) at the end of synset_from_pos_and_offset, but I am not sure that it is worth the additional processing. On the other hand, seek(0) is so cheap an operation that the time penalty would hardly be noticeable.
The text was updated successfully, but these errors were encountered:
Before the recent merge of #2860, wordnet.get_version() would fail whenever a read had already occurred from the data.adj file:
3.0
Synset('able.a.01')
None
The cause of the problem is that synset_from_pos_and_offset goes to a given offset in a data file, reads a line, and stays there. This function is called all the time by other functions in the wordnet module. For ex., in wordnet.doctest, synset_from_pos_and_offset is called indirectly over 10,000 times.
But now that get_version ensures that reading the data.adj starts at byte offset 0, it probably doesn't matter anywhere else, because there may not be another function that needs to read from the beginning of the data file.
It might be safer to add data_file.seek(0) at the end of synset_from_pos_and_offset, but I am not sure that it is worth the additional processing. On the other hand, seek(0) is so cheap an operation that the time penalty would hardly be noticeable.
The text was updated successfully, but these errors were encountered: