Skip to content

Commit d89c351

Browse files
author
Mika
committed
fixes for new version
1 parent 2758a5f commit d89c351

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

‎setup.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# Versions should comply with PEP440. For a discussion on single-sourcing
2424
# the version across setup.py and the project code, see
2525
# https://packaging.python.org/en/latest/single_source_version.html
26-
version='1.2.2',
26+
version='1.2.3',
2727

2828
description='An NLP library for Uralic languages such as Finnish and Sami. Also supports Arabic, Russian etc.',
2929
long_description=long_description,

‎test_uralicnlp.py‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
from uralicNLP.cg3 import Cg3, Cg3Pipe
44
from uralicNLP.translate import *
55
from uralicNLP import dependency
6+
from uralicNLP.ud_tools import UD_collection
67
from uralicNLP.dictionary_backends import MongoDictionary
78
import re
9+
from mikatools import *
810

911
uralicApi.get_all_forms("kissa", "N", "fin")
1012

11-
uralicApi.get_transducer("spa", analyzer=True).lookup_optimize()
12-
print(uralicApi.analyze("hola", "spa"))
13-
print(type(uralicApi.get_transducer("spa", analyzer=True)))
14-
print()
13+
#uralicApi.get_transducer("spa", analyzer=True).lookup_optimize()
14+
#print(uralicApi.analyze("hola", "spa"))
15+
#print(type(uralicApi.get_transducer("spa", analyzer=True)))
16+
#print()
1517
#print(uralicApi.supported_languages())
1618

1719
#uralicApi.download("fin")
@@ -52,7 +54,6 @@
5254
#print (uralicApi.lemmatize("livsmedel", "swe",force_local=True, word_boundaries=True))
5355

5456

55-
5657
"""
5758
for w in ["الكتاب", "الكاتب", "الميكا", "المكتوب", "كلب", "كلبين", "كلاب", "كلبتي", "كلبي", "قلب", "قلبين"]:
5859
print("\n\n" +w)
@@ -64,8 +65,8 @@
6465
6566
str = "+adj{كَلْبِيّ}+masc+sg@"
6667
print(re.findall(r"[ء-ي]+", str))
67-
6868
"""
69+
6970
"""
7071
print(uralicApi.analyze("kissa", "fin"))
7172
print(uralicApi.analyze("on", ["fin","olo"]))
@@ -111,4 +112,10 @@
111112
for word in sentence:
112113
print word.pos, word.lemma, word.get_attribute("deprel")
113114
print "---"
114-
"""
115+
"""
116+
ud = UD_collection(open_read("test_data/fi_test.conllu"))
117+
sentences = ud.find_sentences(query={"lemma": "olla"}) #finds all sentences with the lemma kissa
118+
119+
for sentence in sentences:
120+
word = sentence.find(query={"lemma": "olla"})
121+
print(word[0].get_attribute("form"))

‎uralicNLP/translate.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ def ApertiumStableTranslator():
7676
def ApertiumGiellateknoTranslator():
7777
return ApertiumTranslator("https://gtweb.uit.no/apy/")
7878

79-
def ApertiumJorgalTranslator():
80-
return ApertiumTranslator("http://gtweb.uit.no/jorgal/apy/")
79+
ApertiumJorgalTranslator = ApertiumGiellateknoTranslator
8180

8281
def ApertiumLocalhostTranslator():
8382
return ApertiumTranslator("http://localhost:2737/")

‎uralicNLP/ud_tools.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re, sys
33
from copy import copy
44
import codecs
5+
from typing import Pattern
56

67
if (sys.version_info > (3, 0)):
78
#python 3
@@ -246,7 +247,7 @@ def find(self, query={}, head_query={}, match_range_tokens = False, match_empty_
246247
else:
247248
attr = self.get_attribute(key)
248249
v = query[key]
249-
if isinstance(v, re._pattern_type):
250+
if isinstance(v, Pattern):
250251
if v.match(attr) is None:
251252
passed = False
252253
break
@@ -273,7 +274,7 @@ def find(self, query={}, head_query={}, match_range_tokens = False, match_empty_
273274
else:
274275
attr = getattr(self, key)
275276
v = head_query[key]
276-
if isinstance(v, re._pattern_type):
277+
if isinstance(v, Pattern):
277278
if v.match(attr) is None:
278279
head_pass = False
279280
break

0 commit comments

Comments
 (0)