B
Bernard
Hi all
I already searched on Google, but unfortunately I don't know what it's
exactly called what I'm looking for.
So what I'd like to do is to create a (text-)table and have a script to
find the best match. (Sorry... my english...)
So here's an example:
Table:
#field1 |field2 |field3 |Output
* |* |* |Line1
t* |* |* |Line2
t* |x* |* |Line3
* |x* |x* |Line4
Cases:
Field 1: abc
Field 2: abc
Field 3: abc
Should Match Line1
Field 1: test
Field 2: abc
Field 3: abc
Should match Line2
Field 1: test
Field 2: xyz
Field 3: abc
Should match Line3
Field 1: test
Field 2: xyz
Field 3: xyz
Should match Line4
and so on...
So I'm looking for a way to find the most exact match for given Input.
Is there a module that does this. If not how would you solve it? I know
I should include a some code of what I've already tried, but all the
ways I thought of, are just to complicated and I'm sure there must be an
easier way.
So what I thought of is:
- Build a Hash and then sort by length of key (field 1)... but that
wouldn't work for the 4th example.
- Build 3 Hashes with field 1-3 as keys and sort again by length and
give some kind of rating to the matches (so if field 1 matches with a
String with a lenght of 3 Characters it will get 3 Points)
Thank you very much in advance
Bernard
I already searched on Google, but unfortunately I don't know what it's
exactly called what I'm looking for.
So what I'd like to do is to create a (text-)table and have a script to
find the best match. (Sorry... my english...)
So here's an example:
Table:
#field1 |field2 |field3 |Output
* |* |* |Line1
t* |* |* |Line2
t* |x* |* |Line3
* |x* |x* |Line4
Cases:
Field 1: abc
Field 2: abc
Field 3: abc
Should Match Line1
Field 1: test
Field 2: abc
Field 3: abc
Should match Line2
Field 1: test
Field 2: xyz
Field 3: abc
Should match Line3
Field 1: test
Field 2: xyz
Field 3: xyz
Should match Line4
and so on...
So I'm looking for a way to find the most exact match for given Input.
Is there a module that does this. If not how would you solve it? I know
I should include a some code of what I've already tried, but all the
ways I thought of, are just to complicated and I'm sure there must be an
easier way.
So what I thought of is:
- Build a Hash and then sort by length of key (field 1)... but that
wouldn't work for the 4th example.
- Build 3 Hashes with field 1-3 as keys and sort again by length and
give some kind of rating to the matches (so if field 1 matches with a
String with a lenght of 3 Characters it will get 3 Points)
Thank you very much in advance
Bernard