summaryrefslogtreecommitdiff
path: root/cli/commands/bridge/words.py
diff options
context:
space:
mode:
Diffstat (limited to 'cli/commands/bridge/words.py')
-rw-r--r--cli/commands/bridge/words.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/cli/commands/bridge/words.py b/cli/commands/bridge/words.py
index 27d0bd4..65a67c0 100644
--- a/cli/commands/bridge/words.py
+++ b/cli/commands/bridge/words.py
@@ -10,6 +10,7 @@ import simplejson as json
from tqdm import tqdm
from app.thesaurus.api import Thesaurus
+from app.utils.word_utils import is_oe, is_slang, is_scots, fix_word
@click.command()
@click.option('-a', '--a', 'opt_word_a', required=True,
@@ -115,7 +116,7 @@ class TreeSolver:
queue = []
category_result = self.thesaurus.category(catid)
for category_word in category_result['words']:
- word = self.fix_word(category_word['word'])
+ word = fix_word(category_word['word'])
years = category_word['years'].lower()
if (catid, word,) in self.skips:
continue
@@ -127,11 +128,11 @@ class TreeSolver:
return queue
def process_word(self, word, years, catid, tree, target):
- if not self.include_oe and self.is_oe(years):
+ if not self.include_oe and is_oe(years):
return None
- if not self.include_slang and self.is_slang(years):
+ if not self.include_slang and is_slang(years):
return None
- if not self.include_scots and self.is_scots(years):
+ if not self.include_scots and is_scots(years):
return None
if word not in tree:
tree[word] = tree[catid] + 1
@@ -190,7 +191,7 @@ class TreeSolver:
if self.shuffle:
random.shuffle(category_words)
for category_word in category_words:
- cat_word = self.fix_word(category_word['word'])
+ cat_word = fix_word(category_word['word'])
if cat_word != word and cat_word in tree and self.can_descend(tree, cat_word, word):
chain.append(cat_word)
match = cat_word
@@ -248,18 +249,3 @@ class TreeSolver:
except Exception as e:
return False
- def is_oe(self, years):
- return (('oe' in years and 'oe-' not in years) or 'arch' in years)
-
- def is_slang(self, years):
- return 'slang' in years or 'colloq' in years
-
- def is_scots(self, years):
- return 'Scots' in years
-
- def fix_word(self, word):
- if '<' in word or '/' in word or ',' in word:
- word = word.split("<")[0]
- word = word.split(",")[0]
- word = word.split("/")[0]
- return word.strip()