diff options
| -rw-r--r-- | ext/bg/js/dictionary.js | 18 | ||||
| -rwxr-xr-x | util/compile.py | 41 | 
2 files changed, 32 insertions, 27 deletions
| diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 6870601e..4645189d 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -41,7 +41,8 @@ class Dictionary {              results = results.concat(                  indices.map(index => {                      const [e, r, t, ...g] = dict.defs[index]; -                    return {id: index, expression: e, reading: r, glossary: g, tags: t.split(' ')}; +                    const tags = Dictionary.fixupTags(t.split(' ')); +                    return {id: index, expression: e, reading: r, glossary: g, tags: tags};                  })              );          } @@ -62,4 +63,19 @@ class Dictionary {          return results;      } + +    static fixupTags(tags) { +        const results = []; +        for (const tag of tags) { +            if (tag.startsWith('v5') && tag !== 'v5') { +                results.push('v5'); +            } else if (tag.startsWith('vs-')) { +                results.push('vs'); +            } + +            results.push(tag); +        } + +        return results; +    }  } diff --git a/util/compile.py b/util/compile.py index d5a916fd..1b69bd83 100755 --- a/util/compile.py +++ b/util/compile.py @@ -112,21 +112,21 @@ PARSED_TAGS = {      'v4h':     'Yodan verb with "hu/fu" ending (archaic)',      'v4r':     'Yodan verb with "ru" ending (archaic)',      'v5':      'Godan verb (not completely classified)', -    # 'v5aru':   'Godan verb - -aru special class', -    # 'v5b':     'Godan verb with "bu" ending', -    # 'v5g':     'Godan verb with "gu" ending', -    # 'v5k':     'Godan verb with "ku" ending', -    # 'v5k-s':   'Godan verb - iku/yuku special class', -    # 'v5m':     'Godan verb with "mu" ending', -    # 'v5n':     'Godan verb with "nu" ending', -    # 'v5r':     'Godan verb with "ru" ending', -    # 'v5r-i':   'Godan verb with "ru" ending (irregular verb)', -    # 'v5s':     'Godan verb with "su" ending', -    # 'v5t':     'Godan verb with "tsu" ending', -    # 'v5u':     'Godan verb with "u" ending', -    # 'v5u-s':   'Godan verb with "u" ending (special class)', -    # 'v5uru':   'Godan verb - uru old class verb (old form of Eru)', -    # 'v5z':     'Godan verb with "zu" ending', +    'v5aru':   'Godan verb - -aru special class', +    'v5b':     'Godan verb with "bu" ending', +    'v5g':     'Godan verb with "gu" ending', +    'v5k':     'Godan verb with "ku" ending', +    'v5k-s':   'Godan verb - iku/yuku special class', +    'v5m':     'Godan verb with "mu" ending', +    'v5n':     'Godan verb with "nu" ending', +    'v5r':     'Godan verb with "ru" ending', +    'v5r-i':   'Godan verb with "ru" ending (irregular verb)', +    'v5s':     'Godan verb with "su" ending', +    'v5t':     'Godan verb with "tsu" ending', +    'v5u':     'Godan verb with "u" ending', +    'v5u-s':   'Godan verb with "u" ending (special class)', +    'v5uru':   'Godan verb - uru old class verb (old form of Eru)', +    'v5z':     'Godan verb with "zu" ending',      'vi':      'intransitive verb',      'vk':      'kuru verb - special class',      'vn':      'irregular nu verb', @@ -167,16 +167,6 @@ def parse_kanji_dic(path):      return results -def fixup_godan_verbs(tags): -    results = [] -    for tag in tags: -        if tag.startswith('v5'): -            tag = 'v5' -        results.append(tag) - -    return set(results) - -  def parse_edict(path):      results = []      for line in load_definitions(path): @@ -194,7 +184,6 @@ def parse_edict(path):              dfn_match = re.search(r'^((?:\((?:[\w\-\,\:]*)*\)\s*)*)(.*)$', dfn)              tags_raw = set(filter(None, re.split(r'[\s\(\),]', dfn_match.group(1)))) -            tags_raw = fixup_godan_verbs(tags_raw)              tags_raw = tags_raw.intersection(set(PARSED_TAGS.keys()))              tags = tags.union(tags_raw) |