diff --git a/chinese/behavior.py b/chinese/behavior.py
index 43ac2a2..d9c478d 100644
--- a/chinese/behavior.py
+++ b/chinese/behavior.py
@@ -41,14 +41,6 @@
)
-def get_classifier(hanzi, note):
- cs = dictionary.get_classifiers(hanzi)
- text = ', '.join(colorize_dict(c) for c in cs)
- if text and not has_any_field(config['fields']['classifier'], note):
- return '
Cl: ' + text
- return ''
-
-
def fill_classifier(hanzi, note):
cs = dictionary.get_classifiers(hanzi)
text = ', '.join(colorize_dict(c) for c in cs)
@@ -59,20 +51,17 @@ def fill_classifier(hanzi, note):
return filled
-def get_alt(hanzi, note):
+def fill_alt(hanzi, note):
alts = dictionary.get_variants(hanzi)
alt = ', '.join(colorize_dict(a) for a in alts)
- if alt:
- if not has_any_field(config['fields']['alternative'], note):
- return '
Also written: ' + alt
- if get_first(config['fields']['alternative'], note) == '':
- set_all(config['fields']['alternative'], note, to=alt)
- return ''
+ filled = False
+ if alt and has_any_field(config['fields']['alternative'], note):
+ set_all(config['fields']['alternative'], note, to=alt)
+ filled = True
+ return filled
def fill_def(hanzi, note, lang):
- classifier = get_classifier(hanzi, note)
- alt = get_alt(hanzi, note)
field = {'en': 'english', 'de': 'german', 'fr': 'french'}[lang]
filled = False
@@ -83,7 +72,6 @@ def fill_def(hanzi, note, lang):
if get_first(config['fields'][field], note) == '':
definition = translate(hanzi, lang).removesuffix('\n
')
if definition:
- definition += classifier + alt
set_all(config['fields'][field], note, to=definition)
filled = True
@@ -311,6 +299,7 @@ def update_fields(note, focus_field, fields):
if focus_field in config['fields']['hanzi']:
if copy[focus_field]:
+ fill_alt(hanzi, copy)
fill_all_defs(hanzi, copy)
fill_classifier(hanzi, copy)
fill_transcript(hanzi, copy)
diff --git a/tests/test_behavior.py b/tests/test_behavior.py
index 365c06b..dbeed5c 100644
--- a/tests/test_behavior.py
+++ b/tests/test_behavior.py
@@ -440,27 +440,16 @@ def test_trailing_new_line_removed(self):
class FillAllDefs(Base):
- def test_no_classifier_field(self):
+ def test_fill_all_defs(self):
note = dict.fromkeys(['English', 'German', 'French'], '')
- classifier = (
- '家, '
- '個|'
- '个'
- )
- english = ' \tlibrary
Cl: ' + classifier
- german = ' \tBibliothek (S, Lit)
Cl: ' + classifier
- french = ' \tbibliothèque (lieu)
Cl: ' + classifier
+ english = ' \tlibrary'
+ german = ' \tBibliothek (S, Lit)'
+ french = ' \tbibliothèque (lieu)'
self.assertEqual(fill_all_defs('图书馆', note), 3)
self.assertEqual(note['English'], english)
self.assertEqual(note['French'], french)
self.assertEqual(note['German'], german)
- def test_classifier_field(self):
- note = dict.fromkeys(['Classifier', 'English'], '')
- self.assertEqual(fill_all_defs('图书馆', note), 1)
- self.assertEqual(note['Classifier'], '')
- self.assertEqual(note['English'], ' \tlibrary')
-
class FillClassifier(Base):
def test_fill_classifier(self):