|
1 | 1 | import os |
2 | 2 | import sys |
3 | 3 | import click |
4 | | -from os.path import abspath |
5 | 4 | from plumbum import local |
6 | | -from plumbum.cmd import python, make, bash, git |
| 5 | +from plumbum.cmd import python |
7 | 6 | from stiff.utils.xml import iter_sentences |
8 | 7 | from stiff.data.constants import UNI_POS_WN_MAP |
9 | | -from finntk.wordnet.reader import fiwn_encnt |
10 | | -from finntk.wordnet.utils import fi2en_post |
11 | 8 |
|
12 | 9 |
|
13 | 10 | def get_ukb(): |
@@ -82,39 +79,5 @@ def clean_keyfile(keyin, keyout): |
82 | 79 | keyout.write("\n") |
83 | 80 |
|
84 | 81 |
|
85 | | -@ukb.command() |
86 | | -def fetch(): |
87 | | - os.makedirs("systems", exist_ok=True) |
88 | | - with local.cwd("systems"): |
89 | | - git("clone", "https://github.com/asoroa/ukb.git") |
90 | | - with local.cwd("ukb/src"): |
91 | | - local["./configure"]() |
92 | | - make() |
93 | | - # Prepare |
94 | | - with local.env(UKB_PATH=abspath("systems/ukb/src")): |
95 | | - with local.cwd("support/ukb"): |
96 | | - bash("./prepare_wn30graph.sh") |
97 | | - (python[__file__, "mkwndict", "--en-synset-ids"] > "support/ukb/wndict.fi.txt")() |
98 | | - |
99 | | - |
100 | | -@ukb.command() |
101 | | -@click.option("--en-synset-ids/--fi-synset-ids") |
102 | | -def mkwndict(en_synset_ids): |
103 | | - lemma_names = fiwn_encnt.all_lemma_names() |
104 | | - |
105 | | - for lemma_name in lemma_names: |
106 | | - lemmas = fiwn_encnt.lemmas(lemma_name) |
107 | | - synsets = [] |
108 | | - for lemma in lemmas: |
109 | | - synset = lemma.synset() |
110 | | - post_synset_id = fiwn_encnt.ss2of(synset) |
111 | | - if en_synset_ids: |
112 | | - post_synset_id = fi2en_post(post_synset_id) |
113 | | - synsets.append("{}:{}".format(post_synset_id, lemma.count())) |
114 | | - if not lemma_name: |
115 | | - continue |
116 | | - print("{}\t{}".format(lemma_name, " ".join(synsets))) |
117 | | - |
118 | | - |
119 | 82 | if __name__ == "__main__": |
120 | 83 | ukb() |
0 commit comments