LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

repeatability of words in an array

Solved!
Go to solution

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..

 

 

 

0 Kudos
Message 1 of 10
(5,440 Views)

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.

Message 2 of 10
(5,414 Views)
Solution
Accepted by hameedkdnl

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.

 

 

Download All
Message 3 of 10
(5,398 Views)

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.

0 Kudos
Message 4 of 10
(5,381 Views)

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. 😄

Message 5 of 10
(5,342 Views)

Altenbach,

the link u hav given is for int datatype and is not working for strings.can u pls explain this for string.

0 Kudos
Message 6 of 10
(5,285 Views)

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. 😉

0 Kudos
Message 7 of 10
(5,278 Views)

I have done using some loopings..but it not working properly..need some changes..pls help..

0 Kudos
Message 8 of 10
(5,265 Views)

I have done using some loopings..but it not working properly..need some changes..pls help..

0 Kudos
Message 9 of 10
(5,265 Views)

@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!

0 Kudos
Message 10 of 10
(5,249 Views)