LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check to see if a string is "close enough" to what is expected

I have a silly question which I think I know the answer to but I am wondering if someone has tackled this.

 

What I am after is an algorithm that looks at text that is entered (or coming from one source) and compares it from another source. Now, this text might have an extra space, a dash, or even misplaced words but the algorithm says "yeah, that is what the user is looking for."

 

Is what I am asking not possible? My scenario is data coming from two different sources looking at the same data, which may be slightly off, but neither system knows about the other.

 

I have an example VI below but I am at a loss on how to implement what I want.

0 Kudos
Message 1 of 13
(1,700 Views)

I believe I may have a solution. A simple Google search for "check that two strings are close enough" came up with the  Levenshtein Distance Algorithm to implement into my VI.

0 Kudos
Message 2 of 13
(1,681 Views)

Looks like a few people have been down that path; maybe you won't have to run your own!

 

https://forums.ni.com/t5/LabVIEW/String-similarity/td-p/1332452

 

https://lavag.org/topic/22309-string-similarity-in-g/

 

Message 3 of 13
(1,657 Views)
0 Kudos
Message 4 of 13
(1,641 Views)

I'll admit...I like being challenged so, I decided to tackle this via the website I posted.

 

I am having difficulty deciphering this piece of the Java code:

 

for (i = 0; i<=n; i++) {
p[i] = i;
}

 

I think it is just placing numeric values into an array. Is that correct? Attached is the LV code (2021) plus I copied the code from the website into a comment box.

0 Kudos
Message 5 of 13
(1,601 Views)

Paul - I am not sure if yours would work. Maybe I am just looking at this from the website I posted but aren't you comparing the two words character for character?

0 Kudos
Message 6 of 13
(1,596 Views)

@Eric1977 wrote:

 

for (i = 0; i<=n; i++) {
p[i] = i;
}


I am not used to Java programming (actually, I've never programmed in it before) but it's just a For Loop incrementing one digit to the p array, correct?

0 Kudos
Message 7 of 13
(1,568 Views)

@Eric1977 wrote:

Paul - I am not sure if yours would work. Maybe I am just looking at this from the website I posted but aren't you comparing the two words character for character?


No.  It's recursive and correctly implements a Levenshtein Distance Algorithm.

0 Kudos
Message 8 of 13
(1,556 Views)

@Eric1977 wrote:

@Eric1977 wrote:

 

for (i = 0; i<=n; i++) {
p[i] = i;
}


I am not used to Java programming (actually, I've never programmed in it before) but it's just a For Loop incrementing one digit to the p array, correct?


Here's the equivalent LabVIEW code:

l.png

Message 9 of 13
(1,554 Views)

@paul_a_cardinale wrote:

@Eric1977 wrote:

@Eric1977 wrote:

 

for (i = 0; i<=n; i++) {
p[i] = i;
}


I am not used to Java programming (actually, I've never programmed in it before) but it's just a For Loop incrementing one digit to the p array, correct?


Here's the equivalent LabVIEW code:

l.png


Is there a '+1' missing between the control 'n' and the 'N' terminal of the for loop?

0 Kudos
Message 10 of 13
(1,531 Views)