Skip to content

Commit f18fa5b

Browse files
committed
Merge branch 'master' of github.com:mideind/Greynir
2 parents b5e91b0 + e9935e4 commit f18fa5b

File tree

26 files changed

+108
-170
lines changed

26 files changed

+108
-170
lines changed

.github/workflows/python-package.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010

1111
jobs:
1212
build:
13-
1413
runs-on: ubuntu-latest
1514

1615
# Service containers to run with `container-job`
@@ -37,7 +36,7 @@ jobs:
3736
3837
strategy:
3938
matrix:
40-
python-version: ["3.9"]
39+
python-version: ["3.9", "3.12", "pypy3.9", "pypy3.10"]
4140

4241
steps:
4342
- uses: actions/checkout@v4
@@ -51,12 +50,9 @@ jobs:
5150
sudo update-locale
5251
- name: Install dependencies
5352
run: |
54-
pip cache purge
55-
pip install --upgrade pip wheel setuptools pytest curlylint
56-
pip install --upgrade git+https://github.com/mideind/Tokenizer#egg=tokenizer
57-
pip install --upgrade git+https://github.com/mideind/GreynirEngine#egg=reynir
58-
pip install --upgrade git+https://github.com/mideind/Icespeak#egg=icespeak
59-
pip install --upgrade -r requirements.txt
53+
pip install uv
54+
uv pip install --system --upgrade wheel setuptools pytest curlylint
55+
uv pip install --system --upgrade -r requirements.txt
6056
sudo npm i -g jshint
6157
sudo apt-get install shellcheck
6258
- name: Set up database

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,13 @@ p3*/
125125
p7*/
126126
pypy/
127127
pypy*
128+
pypy39/*
129+
pypy310/*
128130
cpython*/
129131
venv
132+
p312/*
133+
p313/*
134+
p39/*
130135

131136
# Installer logs
132137
pip-log.txt

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ database and processed by grammatical pattern matching modules to obtain stateme
2929
of fact and relations between stated facts.
3030

3131
An overview of the technology behind Greynir can be found in the paper
32-
[A Wide-Coverage Context-Free Grammar for Icelandic
33-
and an Accompanying Parsing System](https://acl-bg.org/proceedings/2019/RANLP%202019/pdf/RANLP160.pdf)
34-
by Vilhjálmur Þorsteinsson, Hulda Óladóttir and Hrafn Loftsson *(Proceedings of Recent Advances in Natural Language Processing, pages 1397–1404, Varna, Bulgaria, Sep 2–4, 2019).*
32+
[A Wide-Coverage Context-Free Grammar for Icelandic and an Accompanying
33+
Parsing System](https://acl-bg.org/proceedings/2019/RANLP%202019/pdf/RANLP160.pdf)
34+
by Vilhjálmur Þorsteinsson, Hulda Óladóttir and Hrafn Loftsson
35+
*(Proceedings of Recent Advances in Natural Language Processing,
36+
pages 1397–1404, Varna, Bulgaria, Sep 2–4, 2019).*
3537

3638
<a href="https://raw.githubusercontent.com/mideind/Greynir/master/static/img/tree-example.png" title="Greynir parse tree">
3739
<img src="static/img/tree-example-small.png" width="400" height="450" alt="Greynir parse tree">
@@ -57,10 +59,11 @@ structured, recursive trees that directly correspond to the original grammar.
5759
These trees can then be further processed and acted upon by sets of Python
5860
functions that are linked to grammar nonterminals.
5961

60-
**Greynir is currently able to parse about *90%* of sentences** in a typical news article from the web,
61-
and many well-written articles can be parsed completely. It presently has well over a million parsed articles
62-
in its database, containing more than 16 million parsed sentences. A relatively recent (2021) version of this
63-
database is available via the [GreynirCorpus](https://github.com/mideind/GreynirCorpus) project.
62+
**Greynir is currently able to parse about *90%* of sentences** in a typical news article
63+
from the web, and many well-written articles can be parsed completely. It presently has about
64+
1.3 million parsed articles in its database, containing about 18 million parsed sentences.
65+
A 2021 version of this database is available via the
66+
[GreynirCorpus](https://github.com/mideind/GreynirCorpus) project.
6467

6568
Greynir supports natural language querying of its databases. Users can ask about person names, titles and
6669
entity definitions and get appropriate replies. The HTML5 Web Speech API is supported to allow
@@ -235,7 +238,7 @@ See [Contributing to Greynir](CONTRIBUTING.md).
235238

236239
## License
237240

238-
Greynir is Copyright &copy; 2023 [Miðeind ehf.](https://mideind.is)
241+
Greynir is Copyright &copy; 2025 [Miðeind ehf.](https://mideind.is)
239242
The original author of this software is *Vilhjálmur Þorsteinsson*.
240243

241244
<a href="https://mideind.is"><img src="static/img/mideind-horizontal-small.png" alt="Miðeind ehf."

db/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
Float,
4040
Sequence,
4141
Boolean,
42-
DateTime, # type: ignore # Imported for re-export
42+
DateTime, # type: ignore # noqa: F401 # Imported for re-export
4343
UniqueConstraint,
4444
Index,
4545
ForeignKey,

images.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ def get_staticmap_image(
327327
return None
328328

329329
if r.status_code == 200:
330-
r.raw.decode_content = True
331-
return BytesIO(r.raw.data)
330+
return BytesIO(r.content)
332331

333332
logging.warning(f"Status {r.status_code} when requesting static map image")
334333
return None

main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
QUERIES_UTIL_GRAMMAR_DIR,
6464
)
6565

66-
from reynir.version import __version__ as greynir_version
66+
from reynir import __version__ as greynir_version
6767
from tokenizer import __version__ as tokenizer_version
6868

6969

@@ -101,7 +101,7 @@
101101
app.config["CACHE"] = Cache(app, config={"CACHE_TYPE": cache_type})
102102

103103
# Register blueprint routes
104-
from routes import routes, max_age # type: ignore
104+
from routes import routes, max_age # type: ignore # noqa: E402
105105

106106
app.register_blueprint(routes)
107107

@@ -288,8 +288,7 @@ def inject_nn_bools() -> Dict[str, Union[str, bool]]:
288288
except socket_error as e:
289289
if e.errno == errno.EADDRINUSE: # Address already in use
290290
logging.error(
291-
f"Another application is already running at"
292-
" host {Settings.HOST}:{Settings.PORT}"
291+
f"Another application is already running at host {Settings.HOST}:{Settings.PORT}"
293292
)
294293
sys.exit(1)
295294
else:

processors/disabled/attribs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
4444
"""
4545

46-
from __future__ import annotations
47-
4846
from queries import QueryStateDict
4947
from tree import Node, ParamList, Result, TreeStateDict
5048

queries/builtin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
2727
"""
2828

29-
from typing import Callable, Dict, Iterable, Optional, List, Any, Tuple, cast
30-
from typing_extensions import TypedDict
29+
from typing import Callable, Dict, Iterable, Optional, List, Any, Tuple, cast, TypedDict
3130

3231
import math
3332
from datetime import datetime, timezone

queries/currency.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929

3030
from typing import Any, Dict, List, Mapping, Optional, Sequence, cast
3131

32-
import cachetools # type: ignore
32+
import cachetools
3333
import random
3434
import logging
35+
import xml.etree.ElementTree as ET
3536

3637
from icespeak import gssml
38+
import requests
3739

3840
from queries import Query, QueryStateDict
3941
from queries.util import (
@@ -199,18 +201,19 @@ def QCurAmountConversion(node: Node, params: QueryStateDict, result: Result) ->
199201
result.op = "convert"
200202

201203

204+
_ARION_EXCHR_XML_API_URL = "https://www.arionbanki.is/markadir/gjaldmidlar/gengi/xml-export"
205+
202206
_CURR_API_URL = "https://apis.is/currency/arion"
203207
_CURR_CACHE_TTL = 3600 # seconds
204208

205209

210+
def _fetch_arion_exchange_rates() -> Optional[Dict[str, float]]:
211+
"""Fetch exchange rate data from apis.is and cache it."""
212+
213+
214+
206215
@cachetools.cached(cachetools.TTLCache(1, _CURR_CACHE_TTL))
207216
def _fetch_exchange_rates() -> Optional[Dict[str, float]]:
208-
<<<<<<< Updated upstream
209-
"""Fetch exchange rate data from apis.is and cache it."""
210-
res = query_json_api(_CURR_API_URL)
211-
if not isinstance(res, dict) or "results" not in res:
212-
logging.warning(f"Unable to fetch exchange rate data from {_CURR_API_URL}")
213-
=======
214217
"""Fetch exchange rate data from Arion banki and cache it."""
215218
try:
216219
resp = requests.get(_ARION_EXCHR_XML_API_URL, timeout=5)
@@ -229,13 +232,7 @@ def _fetch_exchange_rates() -> Optional[Dict[str, float]]:
229232
return exchange_rates
230233
except Exception as e:
231234
logging.warning(f"Error fetching exchange rate data from {_ARION_EXCHR_XML_API_URL}: {e}")
232-
>>>>>>> Stashed changes
233235
return None
234-
return {
235-
c["shortName"]: c["value"]
236-
for c in res["results"]
237-
if "shortName" in c and "value" in c
238-
}
239236

240237

241238
def fetch_exchange_rates() -> Optional[Dict[str, float]]:

queries/flights.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
# TODO: Map country to capital city, e.g. "Svíþjóð" -> "Stokkhólmur"
2727
# TODO: Fetch more than one flight using "flight_count"?
2828

29-
from typing import Any, List, Dict, Optional, cast
30-
from typing_extensions import TypedDict
29+
from typing import Any, List, Dict, Optional, cast, TypedDict
3130

3231
import re
3332
import random

0 commit comments

Comments
 (0)