Skip to content

Commit f5e9694

Browse files
authored
refactor/deprecate_inflection (#19)
* refactor/deprecate_inflection authored-by: jarbasai <jarbasai@mailfence.com>
1 parent 428869f commit f5e9694

File tree

4 files changed

+1
-76
lines changed

4 files changed

+1
-76
lines changed

ovos_utils/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import datetime
1818
import kthread
1919
from ovos_utils.network_utils import *
20-
from inflection import camelize, titleize, transliterate, parameterize, \
21-
ordinalize
2220
from ovos_utils.file_utils import resolve_ovos_resource_file, resolve_resource_file
2321

2422

ovos_utils/parse.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from difflib import SequenceMatcher
22
import re
3-
from inflection import singularize as _singularize_en
43
from enum import IntEnum, auto
54
from ovos_utils.log import LOG
65

@@ -101,8 +100,6 @@ def match_all(query, choices, match_func=None, strategy=MatchStrategy.SIMPLE_RAT
101100

102101

103102
def singularize(word, lang="en"):
104-
if lang.startswith("en"):
105-
return _singularize_en(word)
106103
return word.rstrip("s")
107104

108105

@@ -252,61 +249,3 @@ def extract_paragraphs(query, text, lang="en"):
252249
return search_in_text(query, text, lang,
253250
all_matches=True, paragraphs=True)
254251

255-
256-
if __name__ == "__main__":
257-
258-
259-
print("## Searching: intent")
260-
for sent, score in extract_sentences("intent", wiki_dump):
261-
if score > 0.3:
262-
print(sent)
263-
264-
print("## Searching: precise")
265-
for sent, score in extract_paragraphs("precise", wiki_dump):
266-
if score > 0.3:
267-
print(sent)
268-
exit(0)
269-
s = "hello. He said"
270-
for s in split_sentences(s):
271-
print(s)
272-
s = "hello . He said"
273-
for s in split_sentences(s):
274-
print(s)
275-
276-
# no splitting
277-
s = "hello.com"
278-
for s in split_sentences(s):
279-
print(s)
280-
s = "A.E:I.O.U"
281-
for s in split_sentences(s):
282-
print(s)
283-
284-
# ambiguous, but will split
285-
s = "hello.He said"
286-
for s in split_sentences(s):
287-
print(s)
288-
289-
# ambiguous, no split
290-
s = "hello. he said" # could be "Jones Jr. thinks ..."
291-
for s in split_sentences(s):
292-
print(s)
293-
s = "hello.he said" # could be "www.hello.com"
294-
for s in split_sentences(s):
295-
print(s)
296-
s = "hello . he said" # TODO maybe split this one?
297-
for s in split_sentences(s):
298-
print(s)
299-
300-
# test all
301-
s = "Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid a lot for it. Did he mind? Adam Jones Jr. thinks he didn't. In any case, this isn't true... Well, with a probability of .9 it isn't.I know right\nOK"
302-
print(summarize(s))
303-
for s in split_sentences(s):
304-
print(s)
305-
306-
s = "this is {remove me} the first sentence "
307-
print(summarize(s))
308-
s = " this is (remove me) second. and the 3rd"
309-
print(summarize(s))
310-
s = "this is [remove me] number 4! number5? number6. number 7 \n " \
311-
"number N"
312-
print(summarize(s))

requirements/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mycroft-messagebus-client~=0.9.1,!=0.9.2,!=0.9.3
2-
inflection~=0.3
32
pexpect~=4.8
43
requests~=2.25
54
json_database~=0.5

test/test_utils.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
import unittest
2-
from ovos_utils import rotate_list, camel_case_split, camelize, \
3-
transliterate, titleize, parameterize, ordinalize, get_handler_name
2+
from ovos_utils import rotate_list, camel_case_split, get_handler_name
43

54

65
class TestHelpers(unittest.TestCase):
76

8-
def test_inflection_utils(self):
9-
# just imports from inflection package
10-
# https://inflection.readthedocs.io/en/latest/
11-
self.assertEqual(camelize("device_type"), "DeviceType")
12-
self.assertEqual(titleize("MyAwesome_Skill"), "My Awesome Skill")
13-
self.assertEqual(transliterate('Ærøskøbing'), 'rskbing')
14-
self.assertEqual(parameterize("Donald E. Knuth"), 'donald-e-knuth')
15-
self.assertEqual(ordinalize(5), '5th')
16-
self.assertEqual(ordinalize(2), '2nd')
17-
187
def test_utils(self):
198
def some_function():
209
return

0 commit comments

Comments
 (0)