02-18-2014 02:38 AM
I need a logic for this program
Count number of words and number of repeating words of multi line text.Further display the repeating words in that string.
pls help me..
kudos sure..
Solved! Go to Solution.
02-18-2014 03:02 AM
First you need to convert you string to an 1D array of words (e.g. use scan strings for tokens because there are probably several delimiters (space, newline, return, tab, tec.). Then sort the array, so identical words are adjacent. Now you simply loop over the array and watch whenever the element changes. This is a good exercise and there are plenty of examples already in the forum.
There are some fancier and even more elegant ways to count the duplicates, but let's first see how far you get.
When attaching an example program, you should also make sure that the input string contains typical default data.
02-18-2014 03:53 AM - edited 02-18-2014 03:53 AM
altenbach wrote:There are some fancier and even more elegant ways to count the duplicates, but let's first see how far you get.
Here's a cute way using variant attributes. Make sure you fully understand every single detail of the code.
As I said, this is incomplete because it only recognizes "space" as delimiter and will thus not work for multiline strings unless you do some simple adjustments.
02-18-2014 04:22 AM
thank you.
As i am a beginner in labview,i can't understand the use of variant..can u explain me the use of variant there..or pls give me some concept of solving this issue with just loops.
02-18-2014 04:58 AM
You can right-click each node and call up the help.
For a variant free solution, study this example. It only needs a few simple modifications to deal with strings. See how far you get. 😄
02-19-2014 01:39 AM
Altenbach,
the link u hav given is for int datatype and is not working for strings.can u pls explain this for string.
02-19-2014 02:15 AM - edited 02-19-2014 02:16 AM
That's why I said it needs a few simple modifications. 😄
Instead of a 2D array of strings, use a 1D array of a cluster containing a string and an integer. Try to figure it out. 😉
02-19-2014 05:09 AM
I have done using some loopings..but it not working properly..need some changes..pls help..
02-19-2014 05:10 AM
I have done using some loopings..but it not working properly..need some changes..pls help..
02-19-2014 09:42 AM
@hameedkdnl wrote:
I have done using some loopings..but it not working properly..need some changes..pls help..
Whatever you are doing makes no sense. Why don't you simply adapt my old code in the given link?
Here's a quick draft showing both methods. Note that it gives incorrect results if the input array is empty, but that could be corrected easily with a little more code. Try it!