commit 1f5dc55eafd2f633f85eb5fd41cb04e3fb399e19 parent af91885d48d5b1243df1fafc638ed0ebffbe92cc Author: Antoine Amarilli <a3nm@a3nm.net> Date: Mon, 18 Feb 2013 19:37:19 +0100 +buildtrie_list.py Diffstat:
buildtrie_list.py | | | 22 | ++++++++++++++++++++++ |
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/buildtrie_list.py b/buildtrie_list.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +"""From a list of values (arbitrary) and keys (words), create a trie +representing this mapping""" + +# this modified version is used by plint +# see http://gitorious.org/plint + +import buildtrie +import json +import sys + +trie = buildtrie.empty_node() + +for line in sys.stdin.readlines(): + line = line.split() + value = line[0] + word = line[1:] + buildtrie.insert(trie, word+['-', '-'], value) + +print(json.dumps(trie)) +