# Path: languages/utils.py
# def word_triples(word):
#     """
#     >>> list(word_triples('weight'))
#     ['^wei', 'weight', 'eight$']
#     >>> list(word_triples('eightyfive'))
#     ['^eight', 'eighty', 'ghtyf', 'yfi', 'fiv', 'ive', 've$']
#     """
#     groups = ['^'] + list(word_groups(word)) + ['$']
#     for start in range(len(groups) - 2):
#         yield ''.join(groups[start:start + 3])


import os
import sys
import re
from languages.utils import word_triples
#!/usr/bin/env python

# Setup project environment in the parent directory.
sys.path[0] = os.path.dirname(sys.path[0])



ACCEPTABLE_WORD_REGEX = re.compile('^[a-z0-9-]+$')


def count_triples(words, counters):
    rejfile = open('rejected.txt', 'w')
    for word in words:
        word = word.lower().strip()
        word = word.lstrip('*').rstrip('#')
        word = word.replace('\\', '').replace('/', '')
        word = word.replace('~', '').replace('$', '')
        word = word.replace('^', '').replace('`', '')
        word = word.replace('"', '').replace("'", '')
        if not ACCEPTABLE_WORD_REGEX.match(word):
            print >> rejfile, word
            continue

# Path: languages/utils.py
# def word_triples(word):
#     """
#     >>> list(word_triples('weight'))
#     ['^wei', 'weight', 'eight$']
#     >>> list(word_triples('eightyfive'))
#     ['^eight', 'eighty', 'ghtyf', 'yfi', 'fiv', 'ive', 've$']
#     """
#     groups = ['^'] + list(word_groups(word)) + ['$']
#     for start in range(len(groups) - 2):
#         yield ''.join(groups[start:start + 3])


# Path: tools/languages_analyze_wordlist.py
import os
import sys
import re
from languages.utils import word_triples

#!/usr/bin/env python

# Setup project environment in the parent directory.
sys.path[0] = os.path.dirname(sys.path[0])



ACCEPTABLE_WORD_REGEX = re.compile('^[a-z0-9-]+$')


def count_triples(words, counters):
    rejfile = open('rejected.txt', 'w')
    for word in words:
        word = word.lower().strip()
        word = word.lstrip('*').rstrip('#')
        word = word.replace('\\', '').replace('/', '')
        word = word.replace('~', '').replace('$', '')
        word = word.replace('^', '').replace('`', '')
        word = word.replace('"', '').replace("'", '')
        if not ACCEPTABLE_WORD_REGEX.match(word):
            print >> rejfile, word
            continue

        for triple in word_triples(word):