2017년 5월 5일 금요일

Adding up specific words in text string


I'm looking to be able count specific words in a text string and then display the results as a numeric value. I'm able to count the entire string but I would to get just the specific word. Do able ny of you guys have a snippet you could share? Thanks.
You can output the global number variable to any component you wish.

--
This looks promising. Let me run it later. Thanks from the quick response.

--
Mika is very good. He's help me in the past.

--

"Checks for the word 'you'"

ignore the words those are words of predictive keyboard

--
Thanks for the help. These are my blocks. I'm able to correctly display the total number of words. However, I only get a "1" no matter how many times the word "apple" is listed. Can you see where I'm going wrong?



--
You are initialising ListOfUniqueWords with some logic, which shouldn't be. Instead, create an empty list.
It returns the length of list with word "spoken_word" as you did.

--
Or simply initialize a variable to 0 and increment it inside if block instead of add items to list and display the value of that variable.

--
1. why is there a local variable target word and a global variable target word?
2. the target word is a text and not a list!
3. the for each item in list loop should work together with a list of words and not with your target word

you might want to check again the already provided solutions...



--
yes there are useless local variables

--
Can I substitute the " list of unique words" for my list in my tinydb? It's in there from screen1

--
ListOfUniqueWords is actually a list of multiple specific words that is generated by the input. So, it's basically an output list which you can find the length of. You should not input something into outcome.

--
Please check this updated arrangement:


It uses variables instead of lists. This should solve any confusion.

--
Thank for the help. I've been doing this coding for about 10 minutes and you guys are a great help.

--
Which argument calls my results from my input from screen1?

--
The input is TextBox.Text and the output is Label2.Text

--
Got it. Let me give that a try. Thanks for your help.

--
That worked. However, when the target word is the first or last item in the list it is not added to the total number of items in the list. Is there an if/then I can add to the blocks to force it to be part of the total?

--
could you please show your blocks? in app Inventor, the index for first item is 1.

--


--
I recently updated the blocks which outputs the result to a variable. That would reduce the need of lists.

Please check this updated arrangement: [image] It uses variables instead of lists. This should solve any confusion.

--
Hey guys, I finally got my app working the way I want to. However when counting specific items in a list the first and the last item are ignored. For instance a list consisting of 1 2 1 4 1 4 3 1 3 1 would ignore the first one in the last one and give a total of 3 ones. This is the same regardless of whether it's a word or a number. Any suggestions how to fix this? Thanks.

--
Are you using the method @pavi2410 suggested? Can you share your blocks?
I've used essentially the same approach and found it worked perfectly:




You can also do partial matches with something like this:




--
My blocks are almost the same. There are a few differences. I'm going to try them when I get home.

--

A youtube component that has a twist


I am making a game app that is mostly finished except for one crucial thing.  I would like to be able to play a youtube video during rounds.  I know about activity starter but the main goal is to play an ad.  If you've played any mobile free to play game you probably understand what I have in mind.  Does anyone know a workaround for this to happen?  Thanks and have a nice day

--
you might want to use AppyBuilder, which offers also features for video ads

--