|
a |
|
b/scripts/conjugate_verbs.py |
|
|
1 |
import warnings |
|
|
2 |
from pathlib import Path |
|
|
3 |
|
|
|
4 |
import context # noqa |
|
|
5 |
import typer |
|
|
6 |
|
|
|
7 |
from edsnlp.conjugator import conjugate |
|
|
8 |
from edsnlp.pipelines.qualifiers.hypothesis.patterns import verbs_eds, verbs_hyp |
|
|
9 |
from edsnlp.pipelines.qualifiers.negation.patterns import verbs as neg_verbs |
|
|
10 |
from edsnlp.pipelines.qualifiers.reported_speech.patterns import verbs as rspeech_verbs |
|
|
11 |
|
|
|
12 |
warnings.filterwarnings("ignore") |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
def conjugate_verbs( |
|
|
16 |
output_path: Path = typer.Argument( |
|
|
17 |
"edsnlp/resources/verbs.csv.gz", help="Path to the output CSV table." |
|
|
18 |
) |
|
|
19 |
) -> None: |
|
|
20 |
""" |
|
|
21 |
Convenience script to automatically conjugate a set of verbs, |
|
|
22 |
using mlconjug3 library. |
|
|
23 |
""" |
|
|
24 |
|
|
|
25 |
all_verbs = set(neg_verbs + rspeech_verbs + verbs_eds + verbs_hyp) |
|
|
26 |
|
|
|
27 |
typer.echo(f"Conjugating {len(all_verbs)} verbs...") |
|
|
28 |
|
|
|
29 |
df = conjugate(list(all_verbs)) |
|
|
30 |
|
|
|
31 |
typer.echo(f"Saving to {output_path}") |
|
|
32 |
|
|
|
33 |
output_path.parent.mkdir(exist_ok=True, parents=True) |
|
|
34 |
df.to_csv(output_path, index=False) |
|
|
35 |
|
|
|
36 |
typer.echo("Done !") |
|
|
37 |
|
|
|
38 |
|
|
|
39 |
if __name__ == "__main__": |
|
|
40 |
typer.run(conjugate_verbs) |