mercredi 19 octobre 2022

How can i test "how English" a sentience is in python? [closed]

I was using the random module in python to create a random sentience out of the following list:

l = ['a','b','c','d','e','f','g','h','i','j','l','m',' ']

I resample this list and output a sentence using join method using the following function:

import random

def generate(l):
    res = random.sample(l,len(l))
    return ''.join(res).title()

Using this function i could print out a random sentence made up from two words, however the two words are not English at all. With increasing length of the given list and with increasing the number of the space (' ') element i can make a bigger sentence with more words.

I want pass the output of this function into another function which tests how English the given input is and will give me 100% if the input is absolutely English. I'm doing this for scientific purposes only. Can anyone help me please




Aucun commentaire:

Enregistrer un commentaire