1. Indexing and searching
- Posted by Tony Steward <figjam at nlc.net.au> Mar 09, 2001
- 423 views
- Last edited Mar 10, 2001
------=_NextPart_000_0009_01C0A97E.ABB96000 charset="iso-8859-1" Hi All, I have a complicated indexing problem that I have no idea how to tackle. 1st some background, I'm a locksmith and we often cut keys to code. = Which means that we take a number stamped on a lock or provided to us by = the manufacturer, I then go to code books or to another code program to = lookup the cutting pattern of the key. Ok now the fun begins. Code series FA1 - FA2700 means there are 2700 codes and the program user = may type "FA0001" or "FA1" and iether way come up with the same answer. = This doesn't look too hard but when this code series is put into a data = base with 10,000 others it gets harder. I'll list a few for you to get = the idea. PROFILE SERIES MINIMUM MAX MASK KEYBLANK =20 T...... 1234 T111111 T444444 0111111 FO21P =20 TC.... 1-1000 TC1 TC1000 001111 FO9 =20 TX.... 1-1859 TX1 TX1859 001111 FO9 =20 ER... 1-195 ER1 ER195 00111 FOT3 =20 ER... 501-695 ER501 ER695 00111 FOT3 =20 ER... 101-295 ER101 ER295 00111 FOT3 =20 ..... 0789 00000 99999 11111 HON24R =20 .....A/Z 04689 00000A 99999Z 111110 NE20 =20 .....F. 04689 00000F0 99999F9 1111101 NE39 =20 Row 1 all codes start with "T" followed by 6 digits but can only use = digits listed in series column (outlined in mask). Row 2 all codes start with "TC" followed numerically from 1 to 1000. IE = TC1, TC2, TC3 and so on to TC1000. Row 7 all codes conatin 5 digits but can only use digits listed in = series column. Row 8 all codes contain 5 digits and one letter. How can a take a users input of TC767 and list all code series (records) = that may contain TC767 given there may be another code series that is = from TC7000 to TC9000 which is similar but not correct. It is also = possible for a user to type TC0767 Or Take a users input of 48644D and find its row. If interested I'll sendanyone privately the entire index so they can get = a better feal for what i want to achieve. Regards Tony Steward Come Visit Me At www.locksdownunder.com ------=_NextPart_000_0009_01C0A97E.ABB96000 charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi All,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>I have a complicated indexing problem = that I have=20 no idea how to tackle.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>1st some background, I'm a locksmith = and we often=20 cut keys to code. Which means that we take a number stamped on a lock or = provided to us by the manufacturer, I then go to code books or to = another code=20 program to lookup the cutting pattern of the key.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Ok now the fun begins.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Code series FA1 - FA2700 means there = are 2700 codes=20 and the program user may type "FA0001" or "FA1" and iether way come up = with the=20 same answer. This doesn't look too hard but when this code series is put = into a=20 data base with 10,000 others it gets harder. I'll list a few for you to = get the=20 idea.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> <TABLE borderColor=3D#000000 cellSpacing=3D1 cellPadding=3D2 width=3D461 = border=3D1> <TBODY> <TR> <TD width=3D"15%" bgColor=3D#c0c0c0 height=3D16><FONT face=3DArial = color=3D#000000=20 size=3D2> <P align=3Dcenter>PROFILE</FONT></P></TD> <TD width=3D"15%" bgColor=3D#c0c0c0 height=3D16><FONT face=3DArial = color=3D#000000=20 size=3D2> <P align=3Dcenter>SERIES</FONT></P></TD> <TD width=3D"19%" bgColor=3D#c0c0c0 height=3D16><FONT face=3DArial = color=3D#000000=20 size=3D2> <P align=3Dcenter>MINIMUM</FONT></P></TD> <TD width=3D"19%" bgColor=3D#c0c0c0 height=3D16><FONT face=3DArial = color=3D#000000=20 size=3D2> <P align=3Dcenter>MAX</FONT></P></TD> <TD width=3D"15%" bgColor=3D#c0c0c0 height=3D16><FONT face=3DArial = color=3D#000000=20 size=3D2> <P align=3Dcenter>MASK</FONT></P></TD> <TD width=3D"18%" bgColor=3D#c0c0c0 height=3D16><FONT face=3DArial = color=3D#000000=20 size=3D2> <P align=3Dcenter>KEYBLANK</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>T......</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>1234</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>T111111</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>T444444</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>0111111</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>FO21P</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>TC....</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>1-1000</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>TC1</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>TC1000</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>001111</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>FO9</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>TX....</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>1-1859</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>TX1</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>TX1859</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>001111</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>FO9</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER...</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>1-195</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER1</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER195</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>00111</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>FOT3</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER...</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>501-695</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER501</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER695</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>00111</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>FOT3</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER...</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>101-295</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER101</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>ER295</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>00111</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>FOT3</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>.....</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>0789</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>00000</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>99999</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>11111</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>HON24R</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>.....A/Z</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>04689</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>00000A</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>99999Z</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>111110</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>NE20</FONT></P></TD></TR> <TR> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>.....F.</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>04689</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>00000F0</FONT></P></TD> <TD width=3D"19%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>99999F9</FONT></P></TD> <TD width=3D"15%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>1111101</FONT></P></TD> <TD width=3D"18%" height=3D16><FONT face=3DArial color=3D#000000 = size=3D2> <P align=3Dleft>NE39</FONT></P></TD></TR></TBODY></TABLE></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Row 1 all codes start with "T" followed = by 6 digits=20 but can only use digits listed in series column (outlined in=20 mask).</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Row 2 all codes start with "TC" = followed=20 numerically from 1 to 1000. IE TC1, TC2, TC3 and so on to = TC1000.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Row 7 all codes conatin 5 digits but = can only use=20 digits listed in series column.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Row 8 all codes contain 5 digits and = one=20 letter.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>How can a take a users input of TC767 = and list all=20 code series (records) that may contain TC767 given there may be another = code=20 series that is from TC7000 to TC9000 which is similar but not correct. = It is=20 also possible for a user to type TC0767</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Or</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Take a users input of 48644D and find = its=20 row.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>If interested I'll sendanyone privately = the entire=20 index so they can get a better feal for what i want to = achieve.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Regards</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Tony Steward</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Come Visit Me At <A=20 NT></DIV> ------=_NextPart_000_0009_01C0A97E.ABB96000--
2. Re: Indexing and searching
- Posted by Kat <gertie at PELL.NET> Mar 09, 2001
- 409 views
- Last edited Mar 10, 2001
On 9 Mar 2001, at 21:42, Tony Steward wrote: > Hi All, > I have a complicated indexing problem that I have no idea how to tackle. > > 1st some background, I'm a locksmith and we often cut keys to code. Which > means that we > take a number stamped on a lock or provided to us by the manufacturer, I then > go to code > books or to another code program to lookup the cutting pattern of the key. > > Ok now the fun begins. > Code series FA1 - FA2700 means there are 2700 codes and the program user may > type "FA0001" > or "FA1" and iether way come up with the same answer. This doesn't look too > hard but when > this code series is put into a data base with 10,000 others it gets harder. > I'll list a > few for you to get the idea. > > PROFILE > SERIES > MINIMUM > MAX > MASK > KEYBLANK > > T...... > 1234 > T111111 > T444444 > 0111111 > FO21P > > TC.... > 1-1000 > TC1 > TC1000 > 001111 > FO9 > > TX.... > 1-1859 > TX1 > TX1859 > 001111 > FO9 > > ER... > 1-195 > ER1 > ER195 > 00111 > FOT3 > > ER... > 501-695 > ER501 > ER695 > 00111 > FOT3 > > ER... > 101-295 > ER101 > ER295 > 00111 > FOT3 > > ..... > 0789 > 00000 > 99999 > 11111 > HON24R > > .....A/Z > 04689 > 00000A > 99999Z > 111110 > NE20 > > .....F. > 04689 > 00000F0 > 99999F9 > 1111101 > NE39 > > > > Row 1 all codes start with "T" followed by 6 digits but can only use digits > listed in > series column (outlined in mask). Row 2 all codes start with "TC" followed > numerically > from 1 to 1000. IE TC1, TC2, TC3 and so on to TC1000. Row 7 all codes conatin > 5 digits but > can only use digits listed in series column. Row 8 all codes contain 5 digits > and one > letter. > > How can a take a users input of TC767 and list all code series (records) that > may contain > TC767 given there may be another code series that is from TC7000 to TC9000 > which is > similar but not correct. It is also possible for a user to type TC0767 Or Take > a users > input of 48644D and find its row. Well, i lost the formatting of the records you included, but at first glance this seems easy. The series all start with A-Z chars, and end in 0-9-A-Z, but need not permit a zero after the beginning A-Z chars. <pseudocode> So read in the line, index = 0 while find(line[index],alphaset) do inc index prefix = prefix & line[index] end while suffix = line[index..length(line)] strip the zeros line = prefix & suffix </pseudocode> then loop and find(database[loop],line) the line in a database built by the same rules in the pseudocode above. The first example you gave would look like this in the start of the database: database = { { next line }, etc, } If there is a range you are interested in, then in the loop thru the database, test the field (called a subsequence) to see if it is the proper range: integer PROFILE PROFILE=1 integer SERIES SERIES=2 integer MINIMUM MINIMUM=3 integer MAX MAX=4 etc... if ( line > database[loop][MINIMUM] ) and ( line < database[loop][MAX] ) then -- do something, such as..... for dbindex = PROFILE to KEYBLANK do puts(1,database[dbindex]&"\n") end for end if or since my pseudocode broke line into suffix and prefix already, you might use suffix instead of line, as appropriate. Kat, could have misunderstood the problem.