LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare sentense and word list, then find match

Dear all,

 I am facing a problem on developing my program. One part of my program is to relocation some information. Let me give an example

If I have a sentense,

" I love my happy dog"

and I have a word list

"love" "happy" "happy dog"

I need the program is able to put the sentense into "love" folder, "happy dog" folder, NOT in "happy" folder

Do you have any suggestion how should I do that?

I can think a few different ways, for example sort the word list by giving pioarity to phase, search the highest pioarity phase first, and then mask that phase in the sentense if phase is found in the sentense, but it is too complicate

Please give me some suggestion

thanks

Marco
====================
=Labview 7.0 & 8.0 & 8.5=
=====================
0 Kudos
Message 1 of 4
(3,014 Views)
Sort your word list by length, so that "happy dog" is guaranteed to come before "happy".

To do the sorting, construct an array of clusters { length, phrase }, so that length is FIRST in the cluster.

Then sort the array, and then reverse it (to get them in descending order).

That will guarantee you match "happy" ONLY if you did NOT match "happy dog".

You might need to consider whether you want to be case-sensitive or not.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 4
(2,996 Views)
Thanks for your reply,  could you please tell me how to handle the "love folder"
The senstense is just an example
I have a word list that is a few thousand words long.

Thanks
Marco
====================
=Labview 7.0 & 8.0 & 8.5=
=====================
0 Kudos
Message 3 of 4
(2,987 Views)
I think I mis-read your original post.

You want to put the same sentence into TWO folders: "love" and "happy dog", but not into "happy". Is that right?

But some other sentence you might want to put into a "happy" folder. Is that right?

The only way I see to do that is to somehow disqualify "happy" once you've matched "happy dog".

But you cannot disqualify "love", once you've matched "happy dog".

I think it would help for you to give more examples of sentences, and how you would deal with them.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 4
(2,975 Views)