haspirater

detect aspirated 'h' in French words (local mirror of https://gitlab.com/a3nm/haspirater)
git clone https://a3nm.net/git/haspirater/
Log | Files | Refs | README

buildtrie_list.py (438B)


      1 #!/usr/bin/env python3
      2 
      3 """From a list of values (arbitrary) and keys (words), create a trie
      4 representing this mapping"""
      5 
      6 # this modified version is used by plint
      7 # see https://a3nm.net/git/plint
      8 
      9 import buildtrie
     10 import json
     11 import sys
     12 
     13 trie = buildtrie.empty_node()
     14 
     15 for line in sys.stdin.readlines():
     16   line = line.split()
     17   value = line[0]
     18   word = line[1:]
     19   buildtrie.insert(trie, word+['-', '-'], value)
     20 
     21 print(json.dumps(trie))
     22