Discuss Scratch

AllEverything
Scratcher
4 posts

Help with an AI tokenizer

https://scratch.mit.edu/projects/1308086483
I need help with an AI tokenizer. If you input a message that ends with a space or a symbol, it won't add it to the list processing words (prcwords)
I don't need help making the response or turning the words into token numbers, i just need someone to help fix this bug. Thank you!
THEIMPORTANT
Scratcher
100+ posts

Help with an AI tokenizer

AllEverything wrote:

https://scratch.mit.edu/projects/1308086483
I need help with an AI tokenizer. If you input a message that ends with a space or a symbol, it won't add it to the list processing words (prcwords)
I don't need help making the response or turning the words into token numbers, i just need someone to help fix this bug. Thank you!
Ah, it's clearly visible looking at the project. Before even reaching the end of the list, the loop has already ended. Replace the if/else condition boolean and replace it with:
<<(letter (i) of [input]) = []> and <(letter (i) of [input]) = [ ]>>

Do you see how I added an ‘and’ for an empty character (if you can't see, the first condition is a whitespace and the second is an empty character)? That makes sure it adds the last word even if it does not end with “ ”. If it still does not work, then try changing the length to the length of the input + 1 instead of just the length of the input.
AllEverything
Scratcher
4 posts

Help with an AI tokenizer

THEIMPORTANT wrote:

AllEverything wrote:

https://scratch.mit.edu/projects/1308086483
I need help with an AI tokenizer. If you input a message that ends with a space or a symbol, it won't add it to the list processing words (prcwords)
I don't need help making the response or turning the words into token numbers, i just need someone to help fix this bug. Thank you!
Ah, it's clearly visible looking at the project. Before even reaching the end of the list, the loop has already ended. Replace the if/else condition boolean and replace it with:
<<(letter (i) of [input]) = []> and <(letter (i) of [input]) = [ ]>>

Do you see how I added an ‘and’ for an empty character (if you can't see, the first condition is a whitespace and the second is an empty character)? That makes sure it adds the last word even if it does not end with “ ”. If it still does not work, then try changing the length to the length of the input + 1 instead of just the length of the input.

this unfortunately didn't work. it just sends blank items to the prcwords list corresponding to each letter
THEIMPORTANT
Scratcher
100+ posts

Help with an AI tokenizer

AllEverything wrote:

THEIMPORTANT wrote:

AllEverything wrote:

https://scratch.mit.edu/projects/1308086483
I need help with an AI tokenizer. If you input a message that ends with a space or a symbol, it won't add it to the list processing words (prcwords)
I don't need help making the response or turning the words into token numbers, i just need someone to help fix this bug. Thank you!
Ah, it's clearly visible looking at the project. Before even reaching the end of the list, the loop has already ended. Replace the if/else condition boolean and replace it with:
<<(letter (i) of [input]) = []> and <(letter (i) of [input]) = [ ]>>

Do you see how I added an ‘and’ for an empty character (if you can't see, the first condition is a whitespace and the second is an empty character)? That makes sure it adds the last word even if it does not end with “ ”. If it still does not work, then try changing the length to the length of the input + 1 instead of just the length of the input.

this unfortunately didn't work. it just sends blank items to the prcwords list corresponding to each letter
It appears to me that you unshared your project. Replace the “and” with an “or”.

Powered by DjangoBB