Jump to content

Pattern Recognition Syntax Problem


This topic is 8448 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Here's what I'm trying to do:

I've got 2 fields, that are the same number of character positions each. (Both are text fields, but could easily be number fields if that would help, since each "character position" is either a 1 or a 0.)

One is a global field (call it "g_fieldA").

The other is a calculation field (call it fieldA).

It's entirely possible for one or both of the fields to have several character positions a 1.

I want a calculation field to determine a "match" based on any of the following criteria:

1. If g_fieldA is all 0's, this is a "match" (This part I've solved.)

2. If g_fieldA exactly matches fieldA (i.e., every character position in each matches the other) (This part I've solved.)

3. If for every character position that has a "1" in g_fieldA, there's a "1" in fieldA, this is a match.

Thus this would be a match:

g_fieldA: 00010

fieldA: 00110

Thus this also would be a match:

g_fieldA: 00010

fieldA: 00111

This too would be a match:

g_fieldA: 00110

fieldA: 00111

But this would not be a match:

g_fieldA: 00110

fieldA: 00010

Nor would this:

g_fieldA: 00111

fieldA: 00110

Any ideas? I assume this can be done with some sort of ("0" or "1") approach for each character position, but everything I've tried fails. He

Link to comment
Share on other sites

Give this a try. All fields should be text.

Match? (calculation, text) =

Case(

Length(g_FieldA) <> 5, "No Match",

g_FieldA = "00000", "Match",

Length(FieldA) <> 5, "No Match",

g_FieldA = FieldA, "Match",

PatternCount(g_FieldA, "1") = PatternCount(g_FieldA + FieldA, "2"), "Match",

"No Match")

-bd

[ March 29, 2001: Message edited by: LiveOak ]

Link to comment
Share on other sites

I don't think that will catch every case. For example, gFieldA = 01000, and FieldA = 10000 should not be a match if I understand correctly. This is a bitwise masking operation right?

Anyway, I would try this:

gTempResult = (11111 - TextToNum(FieldA)) - TextToNum(gFieldA)

Case ( gTempResult<0,"no match",

PatternCount(NumToText(gTempResult),"9"),"no match",

"match, whoopee")

Just make sure the constant (11111) in the temporary calculation has as many 1's as you have digits in gFieldA and FieldA

Link to comment
Share on other sites

quote:

Originally posted by BobWeaver:

I don't think that will catch every case. For example, gFieldA = 01000, and FieldA = 10000 should not be a match if I understand correctly. This is a bitwise masking operation right?

Anyway, I would try this:

gTempResult = (11111 - TextToNum(FieldA)) - TextToNum(gFieldA)

Case ( gTempResult<0,"no match",

PatternCount(NumToText(gTempResult),"9"),"no match",

"match, whoopee")

Just make sure the constant (11111) in the temporary calculation has as many 1's as you have digits in gFieldA and FieldA

I don't think this will work either, since 11111-00001-00001 will result in "no match". I think you want to reverse the "no match" and "match, whoopee" cases! = )

Nice solution!

-Dave

Link to comment
Share on other sites

I think you will find it will work. Using this method gFieldA = 01000 and FieldA = 1000 will generate:

pattern count of "1's" for gFieldA = 1

pattery count of "2's" in the sum (gFieldA + FieldA = 11000) is zero and therefore no match

I think you will find that the use of subtraction will not work as is communitive and does not distinguish between which number is in gFieldA and which is in FieldA. A case that doesn't work is both fields equal to 11111, then 11111-11111-11111 = -11111, which tests to no match. Another example gFieldA = 01110 and Field A = 00110, the subtraction gives 9891 for no match. If you reverse the fields gFieldA = 00110 and FieldA = 01110, the subtraction gives 9891, the same, but it should be a match.

-bd

Create12_v2.zip

Link to comment
Share on other sites

Ahhh the debate escalates smile.gif" border="0

Right you are LiveOak. The subtraction as I posted it doesn't work, and I had misread your calculation.

Actually the subtraction method can work, the correct method is actually simpler than what I originally showed:

gTempResult = FieldA - gFieldA

the case statement that I gave before remains the same.

So, now there's two methods, unless I did something dumb again.

Link to comment
Share on other sites

  • Newbies

Someone else sent me the following, which handles all 3 situations!

Case(TextToNum(gfieldA) = 0,"Function Match",

TextToNum(gfieldA) =TextToNum(fieldA),"Function Match",

TextToNum(gfieldA) >TextToNum(fieldA),"No Function Match",

PatternCount(NumToText(Sum(TextToNum(gfieldA), TextToNum(f fieldA))),"2") = PatternCount(NumToText(TextToNum(gfieldA)), "1"),

"Function Match",

"No Function Match")

Many thanks for all the great ideas!

Tom

Link to comment
Share on other sites

This topic is 8448 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.