Skip to content

Instantly share code, notes, and snippets.

@ZSendokame
Last active January 9, 2024 03:00
Show Gist options
  • Save ZSendokame/200762cd35881bb3dc8c257dea84fdc9 to your computer and use it in GitHub Desktop.
Save ZSendokame/200762cd35881bb3dc8c257dea84fdc9 to your computer and use it in GitHub Desktop.
Text prediction using your own datasets. Works by searching matches and then cutting out unnecesary segments. Still working on it
def algorithm(dataset: list, input: str, output_length: int = None) -> str:
matches = filter(lambda quote: input in quote, dataset)
processed = map(lambda quote: quote[quote.index(input):], matches)
return [segment[0:output_length] for segment in processed]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment