LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare text in columns

Hi all,

I tried posting this last night, but it doesn't seem to have worked.

I am trying to compare 2 lists of words using LabView.  My example was something like this:

I have 1 column containing M words:

ball
jack
jill
barbecue
lamb

etc..

and one containing N passages of text. 

jack and jill went up the hill...
mary had a little lamb...
see spot run...

etc...

I want to test a logical condition like: If 1st entry from colum1 is in 1st entry from column2 then return 1, if not return 0.  If 2nd entry from colum1 is in 1st entry from column2... etc

The result should be an M(cols)xN(rows) array of 1's and zeros.  In the above example, it should look like this:

01100... (because of jack and jill)
00010... (becuse of the lamb)
00000...
...etc

Any help with this would be greatly appreciated.

Many thanks,

Chris
0 Kudos
Message 1 of 13
(3,237 Views)

Hi Chris,

try this. Smiley Happy

Mike

Message 2 of 13
(3,226 Views)
duplicate post

Sniff sniff.. smells a bit like a homework problem


Message Edited by smercurio_fc on 03-07-2008 10:54 AM
0 Kudos
Message 3 of 13
(3,199 Views)
Hi this is great - I have an error, though.  It says my the sink is a string and the input is a subset of a 1-d string.  I'm not at all sure what this means - is it a simple case of changing the type of my input?

P.S. sorry about the double post.  I couldn't find the original post so I assumed it had been deleted for some reason (also, I'm a little old to be doing homework!)
0 Kudos
Message 4 of 13
(3,183 Views)
Hi Chris,
what do you mean? Can you upload your vi with the error?
Mike
0 Kudos
Message 5 of 13
(3,178 Views)
Yeah - here it is. 

One more thing.  Is it case insensitive?  I need "jack" and "Jack" to be synonymous.  My limited experience of labview has been numeric - using it for words is untrodden ground for me!

Thanks again!
Download All
0 Kudos
Message 6 of 13
(3,164 Views)
You need to set the auto-indexing properly for the loops. When you wire an array to the boundary of a for-loop the for-loop is auto-indexed, which means it knows how many times it needs to run. If you open Mike's example you will see that when the arrays hit the boundary of the loops they either show up as filled in squares or as a hollow square with a "[ ]" symbol inside. The former means the array is being wired straight through, and is having no effect on the for-loop. The latter means it is controlling the iterations of the for-loop. If you place the cursor over this tunnel the tip that pops up calls these as "Loop Tunnel" or "Auto-Indexed Tunnel".

To deal with the case sensitiviy, use the "To Lower Case" or "To Upper Case" string functions prior to feeding the strings to the Match Pattern function.

I would suggest trying to code this yourself given the explanation, as it is better for you to learn (regardless of how old you may be) Smiley Wink.

To learn more about LabVIEW it is recommended that you go through the tutorial and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials.
0 Kudos
Message 7 of 13
(3,158 Views)
Hi - Thanks for the help.  The program's coming along well.  I have managed to get the program to stop picking up say the word "foot" in a paragraph which only has the word "footwell" by concatenating spaces onto either end of each word that I'm searching for.  However, I also need to be able to detect the word when they are at the end of a sentence or in brackets etc.  so the input of foot would return 1 for:
foot.
(foot)
/foot
-foot!
etc
but zero for
footing
foothill
etc
 
Is there a generic piece of code for this?  I had a rummage of the site for this a while back, but no joy.  It seems like the sort of thing that someone would be likely to have programmed before.  I can't think of a way of programming it without slowing my whole program down.
 
Once again- any pointers would be greatly appreciated.
 
Chris
0 Kudos
Message 8 of 13
(3,106 Views)

Hi pickslide5,

i think this is not easy. Do you no the exact rule for it? You could define ranges. For example 50% of the word length have to be at the beginning of the word before the match. Or you think about neural networks, so your programm learns from the human if one match can be used and one not.

Hope this helps a little bit.

Mike

0 Kudos
Message 9 of 13
(3,100 Views)
at the moment the program is asking:

if
"stringX" exists in "stringY"
then
return 1
if not
return 0

"stringX" is a word and "stringY" is a passage of text
also,
"stringX" is part of an array.  So every item in that array is tested on "stringY" and therefore the output retains the order of the "stringX" array.

What I need to do is say

if "stringX" or "stringX." or "-stringX" or "(stringX)" or etc...
for every combination of the set of characters that may be found attached to a word in a sentence (I am happy enough to include hyphenated words so while "footwell" in the example above is not ok "foot-well" would be fine).
...exists in "stringY"... etc

The trick is to retain the order of the stringX array while doing this and not introduce the "combinations" listed above as new elements but keep them as the same element in the array.
0 Kudos
Message 10 of 13
(3,089 Views)