Home AMX User Forum NetLinx Studio

New Keyword Wish

I have been thinking of a new keyword/arithmetic/logic comparison request...

I'd like something like equals_with_strength.

The idea is you could do a comparison of two strings with the 'strength of match' in play.

For example

Given:
cTEXT_1='ABCDEF'
cTEXT_Incoming // a string coming in from something...

So,

result=equals_with_strength(cTEXT_1,cTEXT_Incoming)


Let cTEXT_Incoming='ABCDEF'

This is an exact char for char match in the correct order with no extra chars. So, the result would be 100%

now.
Let cTEXT_Incoming='ABCdef'

cText_1 matches on 3 occasions 'ABC' and kinda matches on 'DEF' (2nd variable is lowercase) So, it would return a match strength of say 90%

Let cTEXT-_Incoming='abcdef'

Then the return could be 80%. same letter in same order but all lower case


Let cTEXT-_Incoming='ACEFBD'

then the return could be 50% since it contalns all the chars but in the wrong order.

I kinda making up the percentages but I think you get the drift.

There is actually a reason for wanting this.

(and yes, I know I could write it myself...)

Comments

  • mpullinmpullin Posts: 949
    So basically you want a function for calculating Levenshtein distance within NetLinx?
  • ericmedleyericmedley Posts: 4,177
    mpullin wrote: »
    So basically you want a function for calculating Levenshtein distance within NetLinx?
    Well, kinda

    You'd have to modify it quite a bit to get what I'm looking for.

    For example I'll create it for what I had in mind.

    Let's say I'm doing cable channel lineups and the string from the XML file is

    2 ABC-WCBD Charleston

    and I had my own data matrix that was storing it.

    But next week the string said someting like

    4 WCBD-HD Count On 2HD - meaning that WCBD was now on cable channel 4 and the label had changed
    I still want to be able to have some way of finding it without regard to what they chose to call it this week.

    In my example I could have a strength match since both strings still contain WCBD and '2' and still get the routine to fire and load in the new channel number.

    It's more of a Constraint Database and Constraint Query Language, I think...
Sign In or Register to comment.