songleash

generate chansons en laisse
git clone https://a3nm.net/git/songleash/
Log | Files | Refs

commit 89b86df701323f63136bb6a035f424856bee393a
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Tue,  4 Aug 2015 02:57:16 -0300

initial

Diffstat:
common.py | 4++++
graph.py | 33+++++++++++++++++++++++++++++++++
only3.py | 15+++++++++++++++
script.sh | 5+++++
4 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/common.py b/common.py @@ -0,0 +1,4 @@ +#!/usr/bin/python3 + +vowels = 'io92EeaOy#$u()' + diff --git a/graph.py b/graph.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import sys +from common import vowels + +g = {} + +for l in sys.stdin.readlines(): + l = l.strip() + w, p = l.split('\t') + p = p.split(' ') + if p[0][0] in vowels: + continue + #f = p[0] + ('' if p[0][0] in vowels else p[1]) + for i in range(len(p[2])+1): + f = p[0] + p[1] + p[2][:i] + t = (p[-2][-1] if p[-1][0] in vowels else (p[-3][-1] + p[-2])) + p[-1] + # print ("%s : %s -> %s" % (w, f, t)) + if f not in g.keys(): + g[f] = set() + g[f].add((t, w)) + +for j in range(100): + print("-----------------") + f = list(g.keys())[j] + print(f) + for i in range(100): + t = list(g[f])[0] + if t[0] not in g.keys(): + continue + print("%s -[%s]-> %s" % (f, t[1], t[0])) + f = t[0] + diff --git a/only3.py b/only3.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 + +from common import vowels +import re +import sys + +for l in sys.stdin.readlines(): + f = l.split('\t') + vowels_regexp = re.compile('([' + vowels + '])') + f[1] = f[1].strip() + parse = re.split(vowels_regexp, f[1]) + parse = [x for x in parse if len(x) > 0] + s = sum([1 for x in parse if x[0] in vowels]) + if s == 3: + print("%s\t%s" % (f[0], ' '.join(parse))) diff --git a/script.sh b/script.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +pv lexique.txt| ./only3.py > lexique3 +cat lexique3 | ./graph.py +