LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Text comparison in labview

Hi,

 

I have to compare to strings with one output string and other expected string and based on some weight-age we have to conclude it is pass or fail.

 

As an example.

 

Output string: Increase temperatures

expected :  Increase temperatures

Result: Pass

Pass % =100

 

Output string: Increase temperature

expected :  Increase temperatures

Result: Pass

Pass % =90

(Note : only s missing in the last character and we can consider this as pass.

 

 

Output string: Increase temperature

expected :  Increase temperahgdve

Result: Fail

Pass % =60

 

Can any one guide me in order to achieve above use cases.

 

IS there any third party tool available which i can integrate with Labview or writing own vi is also fine.

 

Regards,

Anand 

 

0 Kudos
Message 1 of 14
(2,058 Views)

If I had to do something like this, it looks like you're not trying to calculate percentages so we should wipe that off the table.  Rather, you're looking at how many errors you're willing to accept.

You're showing the best case scenarios here.  If everything at the start lines up or everything after mismatches lineup, it's as trivial as using a string subset with an iteration counter to check letters against each other.  You can add up number of errors with a "not equal" being true incrementing a counter held in a shift register.  Once it exceeds the threshold, exit the for loop.

If an extra letter to start shifting the rest should also pass, you'll have to check for that shift after a fail.  That makes things more interesting.

0 Kudos
Message 2 of 14
(2,043 Views)

Thank you natasftw,

 

I got it but did not understand this.

 

"If an extra letter to start shifting the rest should also pass, you'll have to check for that shift after a fail.  That makes things more interesting."

 

How to check the shift in characters.

 

Regards,

Anand

0 Kudos
Message 3 of 14
(1,969 Views)

The question you are really asking involves coming up with a measure of "Difference/Similarity of two Strings", which gets into the kind of algorithms that some text editors (and Web code) use to suggest other words when you type "teh" (and it gets "corrected" to "the") or "Roberx" (corrected to "Robert").  Once you come up with the algorithm (potentially difficult and tricky), implementing it should be relatively simple.

 

My suspicion is that this problem is more difficult than you think, and probably beyond your (or, for that matter, my) ability.

 

Bob Schor

0 Kudos
Message 4 of 14
(1,959 Views)

Hi natasftw,

 

How can i handle this situation like.

 

Expected : Increase temperature

Actual:       Increase emperature.

 

In the above case t is missing in the actual string but it shifted to left. It should be a pass case.

 

I am checking character by character, so it is going to fail. Any idea on this.

 

Regards,

Anand

0 Kudos
Message 5 of 14
(1,864 Views)

@AnandR wrote:

Hi natasftw,

 

How can i handle this situation like.

 

Expected : Increase temperature

Actual:       Increase emperature.

 

In the above case t is missing in the actual string but it shifted to left. It should be a pass case.

 

I am checking character by character, so it is going to fail. Any idea on this.

 

Regards,

Anand


This is no trivial thing.  I suggest limiting the user input, instead.  Maybe a ring or enum for instance.  It's always better to prevent the user from making a mistake than to correct it once they have.


Edit:

Oops, I didn't realize that this was OUTPUT.  Why are you expecting garbled output?  Treat the problem, not the symptom.


Edit2:

Ater re-re-reading it, I realize I'm far off from what the OP was asking.  Sorry, I guess it's safe to ignore this post.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 14
(1,844 Views)

@Bob_Schor wrote:

The question you are really asking involves coming up with a measure of "Difference/Similarity of two Strings",

...

Once you come up with the algorithm (potentially difficult and tricky), implementing it should be relatively simple.

 

My suspicion is that this problem is more difficult than you think, and probably beyond your (or, for that matter, my) ability.


I really think @Bob_Schor got it right. There are many algorithms out there (a Google search returned this StackOverflow question and this Wikipedia article, to provide some quick examples).

 

As a coding exercise, I created the attached example (using an algorithm I made up on the spot). It could be used as a starting point, but there are some particular errors that it cannot catch (like an output string of "Increase temperatures-asojfhapk" that will return as a perfect match). It would be better to instead take an existing algorithm designed for this purpose.

 

(Also, I'm pretty inexperienced, so I wouldn't be surprised if some of this fits well into the Rube-Goldberg thread...it really should be coded from scratch with a better algorithm.)

 

-joeorbob

 

0 Kudos
Message 7 of 14
(1,801 Views)

Hi joeorbob,

 

Could you build this vi in Labview 2014 .

 

Regards,

Anand

0 Kudos
Message 8 of 14
(1,772 Views)

JoeOrBob shouldn't have to do "extra work" to save you from "trying to do this yourself".  I took the trouble to open his VI and take a "Snippet", which makes a "picture" (and I have been known to yell and scream about posting "pictures of code", but I forgive myself here because (a) the code is exceptionally neat and well-documented, (b) it is simple and "compact", and (c) there are no "hidden features" (like Case Statements or sub-VIs) that "hide details".

 

Feel free to spend your time re-creating it.

 

JoeOrBob String Comparison.png

 

Bob Schor

Message 9 of 14
(1,755 Views)

Hi Bob Schor,

 

Thank you.  I was not able to open the vi since my development system is  2014.

 

Just to know, can i open the vi in 2014 which is built in 2015?

0 Kudos
Message 10 of 14
(1,719 Views)