import secrets

from . import lexique

lex = lexique.Lexique.parse()


def gen_phrase4():
    out = []
    out.append(secrets.choice(lex.most_common(lexique.CatGram.ADJECTIF)))
    out.append(secrets.choice(lex.most_common(lexique.CatGram.NOM)))
    out.append(secrets.choice(lex.most_common(lexique.CatGram.VERBE)))
    out.append(secrets.choice(lex.most_common(lexique.CatGram.NOM)))
    return " ".join(map(lambda x: x.word, out))


def gen_rand(n=4):
    out = []
    for _ in range(n):
        cat = secrets.choice(
            (
                lexique.CatGram.ADJECTIF,
                lexique.CatGram.NOM,
                lexique.CatGram.VERBE,
                lexique.CatGram.ADVERBE,
            )
        )
        out.append(secrets.choice(lex.most_common(cat)))
    return " ".join(map(lambda x: x.word, out))


def gen_nom(n=4):
    out = []
    for _ in range(n):
        cat = lexique.CatGram.NOM
        out.append(secrets.choice(lex.most_common(cat)))
    return " ".join(map(lambda x: x.word, out))