mideind / binpackage Goto Github PK
View Code? Open in Web Editor NEWThe vocabulary of modern Icelandic, encapsulated in a Python package
License: MIT License
The vocabulary of modern Icelandic, encapsulated in a Python package
License: MIT License
Ég hef verið að nota Greyni og BÍN mikið nýverið og í kvöld byrjaði ég að fá dularfulla villu frá Greyni, þegar ég reyni að þátta setningar.
Dæmi:
g = Greynir() g.parse_single('ég fór í bæinn og keypti ís')
Fyrir mismunandi input þá kom þessi KeyError úr islenska/basics.py og í rótinni kom alltaf sama "KeyError: 'PRússlandskonung'`" villan.
Þetta lagaðist þegar ég restartaði sessioninu í jupyter, en mér datt í hug að láta vita af þessu.
KeyError Traceback (most recent call last)
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\islenska\basics.py in lookup(self, key, func)
353 try:
--> 354 result = self.cache[key]
355 self.hits += 1
KeyError: 'keypti'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_1092/3409655977.py in <module>
----> 1 g.parse_single('ég fór í bæinn og keypti ís')
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\reynir.py in parse_single(self, sentence, max_sent_tokens)
873 # Returns None if no sentence could be extracted from the text
874 try:
--> 875 return next(iter(job))
876 except StopIteration:
877 return None
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\reynir.py in sentences(self)
559 def sentences(self) -> Iterable[_Sentence]:
560 """ Yield the sentences from the token stream """
--> 561 for p in self.paragraphs():
562 yield from p.sentences()
563
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\reynir.py in paragraphs(self)
554 # No progress function: use generators throughout
555 plist = paragraphs(self._tokens)
--> 556 for p in plist:
557 yield _Paragraph(self, p)
558
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\tokenizer\tokenizer.py in paragraphs(tokens)
3014 current_p: List[Tuple[int, List[Tok]]] = [] # Current paragraph
3015
-> 3016 for ix, t in enumerate(tokens):
3017 t0 = t[0]
3018 if t0 == TOK.S_BEGIN:
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bintokenizer.py in disambiguate_phrases(token_stream, token_ctor)
2018
2019 ds = DisambiguationStream(token_ctor)
-> 2020 yield from ds.process(token_stream)
2021
2022
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bintokenizer.py in process(self, token_stream)
1773 while True:
1774
-> 1775 token = next(token_stream)
1776
1777 if token.txt is None:
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bintokenizer.py in fix_abbreviations(token_stream)
1707 token = next(token_stream)
1708 while True:
-> 1709 next_token = next(token_stream)
1710 # If we have a 'name finisher abbreviation'
1711 # (such as 'próf.' for 'prófessor') and the next token
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bintokenizer.py in parse_phrases_3(db, token_stream, token_ctor)
1649 # Make sure that token is None if next() raises StopIteration
1650 token = cast(Tok, None)
-> 1651 token = next(token_stream)
1652 continue
1653 next_token = next(token_stream)
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bintokenizer.py in parse_phrases_2(token_stream, token_ctor, auto_uppercase)
1086
1087 while True:
-> 1088 next_token = next(token_stream)
1089
1090 # Make the lookahead checks we're interested in
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\tokenizer\tokenizer.py in __next__(self)
859 if self.__lookahead:
860 return self.__lookahead.popleft()
--> 861 return next(self.__it)
862
863 def __iter__(self):
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bintokenizer.py in parse_phrases_1(db, token_ctor, token_stream)
845 token = next(token_stream)
846 while True:
--> 847 next_token: Tok = next(token_stream)
848
849 # Logic for numbers that are partially or entirely
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bintokenizer.py in annotate(db, token_ctor, token_stream, auto_uppercase, no_sentence_start)
637 # If word is found in PREFER_LOWERCASE we skip searching uppercase meanings
638 # (if auto_uppercase is True)
--> 639 w, m = db.lookup_g(
640 w, at_sentence_start, auto_uppercase and w not in PREFER_LOWERCASE
641 )
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\reynir\bindb.py in lookup_g(self, w, at_sentence_start, auto_uppercase)
76 """ Returns BIN_Tuple instances, which are the Greynir version
77 of islenska.BinEntry """
---> 78 w, m = self._lookup(
79 w,
80 at_sentence_start,
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\islenska\bindb.py in _lookup(self, w, at_sentence_start, auto_uppercase, lookup_func, ctor)
386 # Start with a straightforward, cached lookup of the word as-is
387 lower_w = w
--> 388 m: List[_T] = lookup_func(w)
389
390 if auto_uppercase and w.islower():
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\islenska\bindb.py in _meanings_cache_lookup(self, key, compound)
290 """ Attempt to lookup a word in the cache,
291 returning a list of BinEntry instances """
--> 292 klist = self._ksnid_cache_lookup(key, compound=compound)
293 # Convert the cached ksnid list to a list of BinEntry (SHsnid) tuples
294 return [k.to_bin_entry() for k in klist]
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\islenska\bindb.py in _ksnid_cache_lookup(self, key, compound)
273 """ Attempt to lookup a word in the cache, calling
274 self.ksnid_lookup() on a cache miss """
--> 275 klist = self._ksnid_cache.lookup(key, self._ksnid_lookup)
276 # If we're looking for compound suffixes (compound=True), we
277 # allow items where birting == 'S' (coming from ord.suffix.csv)
c:\users\hp\appdata\local\programs\python\python39\lib\site-packages\islenska\basics.py in lookup(self, key, func)
363 self.maxsize // 10, self.use_count.items(), key=itemgetter(1)
364 ):
--> 365 del self.cache[key], self.use_count[key]
366 return result
367
KeyError: 'PRússlandskonung'
```
>>> from islenska.bincompress import BinCompressed
>>> bin_com = BinCompressed()
>>> bin_com.lookup('Möðrudalsöræfum')
[]
>>> bin_com.lookup('Möðrudalsöræfi')
[('Möðrudalsöræfi', 489454, 'hk', 'örn', 'Möðrudalsöræfi', 'ÞFET'), ('Möðrudalsöræfi', 489454, 'hk', 'örn', 'Möðrudalsöræfi', 'ÞGFET'), ('Möðrudalsöræfi', 489454, 'hk', 'örn', 'Möðrudalsöræfi', 'NFET')]
Möðrudalsöræfi should be plural but bin_com.lookup returns the singular form (which I don't think really exists). I have an old copy of Sigrúnarsnið (downloaded in June 2022) where this also seems to be the case. In the latest version of Sigrúnarsnið, this has been rectified.
I ran the following command from a clean venv folder:
pip install islenska
And got the following error:
(I've removed the actual paths and replaced them with [redacted]
)
Collecting islenska
Using cached islenska-0.4.3.tar.gz (42.3 MB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [48 lines of output]
WARNING: The wheel package is not available.
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cffi
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File "[redacted]/venv/lib/python3.8/site-packages/setuptools/installer.py", line 128, in fetch_build_egg
subprocess.check_call(cmd)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['[redacted]/venv/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/7b/fx44d2qx41bbjn50j4mbmvc00000gn/T/tmpa8ojaoyu', '--quiet', 'cffi>=1.13.0']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/7b/fx44d2qx41bbjn50j4mbmvc00000gn/T/pip-install-40yfuz14/islenska_08a564660857412f9d970585e1cdd450/setup.py", line 61, in <module>
setup(
File "[redacted]/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 164, in setup
_install_setup_requires(attrs)
File "[redacted]/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 159, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "[redacted]/venv/lib/python3.8/site-packages/setuptools/dist.py", line 699, in fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
File "[redacted]/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 779, in resolve
dist = best[req.key] = env.best_match(
File "[redacted]/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1064, in best_match
return self.obtain(req, installer)
File "[redacted]/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1076, in obtain
return installer(requirement)
File "[redacted]/venv/lib/python3.8/site-packages/setuptools/dist.py", line 758, in fetch_build_egg
return fetch_build_egg(self, req)
File "[redacted]/venv/lib/python3.8/site-packages/setuptools/installer.py", line 130, in fetch_build_egg
raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['[redacted]/venv/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/7b/fx44d2qx41bbjn50j4mbmvc00000gn/T/tmpa8ojaoyu', '--quiet', 'cffi>=1.13.0']' returned non-zero exit status 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Running on MacBook Pro, M1 Pro, macOS Monterey version 12.2.1
python version: 3.8
pip version: 22.2.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.