frhyme

guess the last phonemes of a French word
git clone https://a3nm.net/git/frhyme/
Log | Files | Refs | README

commit e450ccca53763715e1832e8b4bad4cbfcb2ca04b
parent f7fabf28906e373c07a7708b72ac89a236659f2b
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Tue, 13 Mar 2012 14:41:19 +0100

remove old file

Diffstat:
majoritytrie.py | 24------------------------
1 file changed, 0 insertions(+), 24 deletions(-)

diff --git a/majoritytrie.py b/majoritytrie.py @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 - -"""Read json trie in stdin, keep majority value at each node and output -trie to stdout""" - -import json -import sys - -trie = json.load(sys.stdin) - -def get_majority(d): - """What is the most probable value?""" - return max(d, key=d.get) - -def majority(trie): - """Keep only the most probable value at each node""" - trie[0] = get_majority(trie[0]) - for child in trie[1].values(): - majority(child) - -majority(trie) - -print(json.dumps(trie)) -