How can I extract each word in a string sentence which are separated by spaces " "

How can I extract each word in a string sentence which are separated by spaces " "
example..
(Hello world its a lovely day)

in a list we have....

Hello
World
Its
A
Lovely
day

Extracting the words and save individually for string comparison testing.
The goal of the code is to extract all words from a sentence and then find out which words from that sentence are more common in a story saved.

For example "Lovely" from the sentence appears 8 times in the story.
"day" appears 12 times.

Just haven't got anything running or where to start. I'm assuming I use [list] for the story and [list] for the words separated in the sentence but when using [segment, text,start,length] it errors when I try and locate the spaces.

thanks

Thomas

.


This does not work, please refer to post #4 by Anke.

Then use a For loop and dictionary to count the times the word appear.

image

1 Like

The new map reduce blocks might be of use here.

Here's a map/reduce attempt.
It might be possible to eliminate that do-result block, if I find a functional way to count and group the words.



test_functional_blocks

P.S. These blocks can be dragged directly into your Blocks Editor workspace.

See A way to group projects by theme - #10 by ABG
for a demo.

1 Like