redfox180 Posted January 13, 2008 Share Posted January 13, 2008 Hello, does anybody know if it's possible to create a webpage where you insert text and the server will filter/modify to whatever you've programmed to do? For example you copy a document similar to this into a webpage: Healthy Food INC. 445 Brighton Rd, Derby... 2xmash potatoes... etc... to: PTA#2MASHPOTATOES#PE$P445DERBY This would be very helpful for me when I need to process invoices or financial documents quickly and insert them into the system. It accepts entry only... Many thanks James Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/ Share on other sites More sharing options...
Ken2k7 Posted January 13, 2008 Share Posted January 13, 2008 Yes, it's possible. I would write a sample, but I have no idea how you got from: Healthy Food INC. 445 Brighton Rd, Derby... 2xmash potatoes... etc... To this: PTA#2MASHPOTATOES#PE$P445DERBY I see where 2xmash potatoes go and 445 derby, but is that it? Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438096 Share on other sites More sharing options...
redfox180 Posted January 13, 2008 Author Share Posted January 13, 2008 ok, we use a unix based system for the airline industry but when it comes to file an invoice it's terrible and slow and I have to translate all the information to different entries. For example to tell the system I want to file an invoice instead of a ticket I have to start with PT followed by A for items etc... So what I am looking for is something that, given a sample text, it translates it to a ready made entry... Cheers Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438107 Share on other sites More sharing options...
GingerRobot Posted January 13, 2008 Share Posted January 13, 2008 It'll all just be string manipulation and regular expressions. Since you've still provided us no idea how to get from the initial data to the output, i can't help you much more than to point you to: www.php.net/preg_replace and http://www.phpfreaks.com/forums/index.php/board,43.0.html Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438129 Share on other sites More sharing options...
redfox180 Posted January 13, 2008 Author Share Posted January 13, 2008 This is a better example: 1 TKT LONNYC BA 22DEC YCHEAP FARE: GBP1 TAXES: GBP1GB GBP10YQ TOTAL: GBP12 to: PTA#RWLONNYC#WWBA#NDYCHEAP#PQGBP1#DSTAX1GB$TAX10YQ This is the best example I can give you without coping a full invoice It is also important that php is reading lines consequentially to avoid mixing. The post you suggested me does not explain how to create a box where you can send it and get back 'translated' text. Also it is just about text replacing... Thanks Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438151 Share on other sites More sharing options...
redfox180 Posted January 13, 2008 Author Share Posted January 13, 2008 The problem with preg_replace is that it just replace given text. Unfortunately` the text changes the only thing that remains the same is the pattern. On the previous example the AIRLINE will always proceed by the CITY PAIR. So, instead of LONNYC BA could be NYCMSP NW but the layout will always be the same. This is way I am looking at something that reads consequentially adding text that will always be the same. For the city pair will always be RW, for airline WW, etc... Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438171 Share on other sites More sharing options...
Barand Posted January 13, 2008 Share Posted January 13, 2008 It's one of those "just" jobs like my wife saying "If you just knock down that wall and move the doorway from here to there...". So you just need to come up with a comprehensive, foolproof set of business rules to define how any variation of input format should be converted to the desired output format. Then it can be coded. Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438237 Share on other sites More sharing options...
GingerRobot Posted January 13, 2008 Share Posted January 13, 2008 It's one of those "just" jobs like my wife saying "If you just knock down that wall and move the doorway from here to there...". Haha. Just remember, there's no point anyway - it'll be wrong and you'll have to put it back how it was before anyway. Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438280 Share on other sites More sharing options...
redfox180 Posted January 13, 2008 Author Share Posted January 13, 2008 So you just need to come up with a comprehensive, foolproof set of business rules to define how any variation of input format should be converted to the desired output format. The rules have already been defined by the software provider. There are about 15. What I cannot understand from anyone is if it is something that php can handle. At the end, it just has to ignore some part of a document and/or precede others with predefined words/numbers... If it's easy to understand, given 2 or more different sentences of 4 words each, add HI to the 1st, ignore 2nd, substitute 3rd with HAVE and add 10 to 4th. EX. I LIKE YOUR CARS BECOMES HI I HAVE 10 CARS Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438328 Share on other sites More sharing options...
trq Posted January 13, 2008 Share Posted January 13, 2008 Because I was bored. #!/usr/bin/php <?php $s = "I LIKE YOUR CARS"; $a = explode(' ',$s); $r = "HI "; for($i=0;$i<=count($a);$i++) { if ($i == 0) { $r .= $a[$i] . " "; } elseif ($i == 1) { $r .= "HAVE "; } elseif ($i == 2) { $r .= "10 "; } elseif ($i == 3) { $r .= $a[$i]; } } echo "$r\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438367 Share on other sites More sharing options...
AndyB Posted January 14, 2008 Share Posted January 14, 2008 What I cannot understand from anyone is if it is something that php can handle. Provided that you can absolutely qualify how every possible input is to be processed, php can do it easily. The hard part - as usual - is defining all of the rules. Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438529 Share on other sites More sharing options...
redfox180 Posted January 14, 2008 Author Share Posted January 14, 2008 Thanks thorpe, it's starting to make sense... Now I have another problem, how can I implement that in a way that in some cases instead of reading words in a consecutive order, it can overrule it for some exceptions? For example: 2 LONNYC AA 9999 Y25JAN 1645 OK YCHEAP 20K -O FCALC LON AA NYC 171.61YCHEAP AA LON 171.61YCHEAP NUC343.22E ND ROE0.495294< I can use an expression to define what I want to change on the first line because they will always be placed in the same order/pattern, but when it comes to modify line 2, I cannot think of anything... On line 2-3 I need php to think to take in consideration everything from the word FCALC to END, this is because you can have calculations of different lengths. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438660 Share on other sites More sharing options...
redfox180 Posted January 14, 2008 Author Share Posted January 14, 2008 If it can help I can write down a couple of tkts and all the entries I need php to convert them to...??? Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438805 Share on other sites More sharing options...
trq Posted January 14, 2008 Share Posted January 14, 2008 If it can help I can write down a couple of tkts and all the entries I need php to convert them to So we can do it for you? Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438869 Share on other sites More sharing options...
redfox180 Posted January 14, 2008 Author Share Posted January 14, 2008 So we can do it for you? The problem with all of this is that I haven't found a straight answer to the problem. I'm not asking how long it's going to take... I just asked whether or not was possible. I just read a couple of tutorials for php, since it's something new for me but I could not find what I'm looking for... Can php create a mask like the one form this example? YTR ETKT 342 2135 538 3544 ACN QQ45414 ISSUED 31DEC07 10.11.2 SNTEN AGT 084532431 UK PNR EWQAU CHEAP AIRLINE INC / WEB SALES< SMITH/COLIN 342 2135 538 3544< 1 LONNYC EW 1252 K 14JAN 0745 OK KCHEAP 20K O 2 NYCLON WE 3229 K 25JAN 1645 OK KCHEAP 20K O FCALC LON EW NYC 171.61KCHEAP WE LON 171.61KCHEAP NUC343.22E ND ROE0.495294< FARE GBP170.00< TAXES GBP10.00GB GBP8.00UB GBP17.20BE GBP29.60YQ< TOTAL GBP234.8< PAYM CASH GBP234.8 This is what I would like php to do... PTQEW #TK 342 2135 538 3544 #IS 31DEC07 #NA SMITH/COLIN #FC LON EW NYC 171.61KCHEAP WE LON 171.61KCHEAP NUC343.22 ETC... As you can see from the example, it's not something that php can handle with a function or a filter. In same cases it has to ignore part of the text some others identify text between two words and some others just count from the top the word number I need... For example the tkt number will always be 3rd from the beginning but the fare calculation is a long sting always different and always between FCALC and END. It also has to add those little entries proceeded by # to the filtered text. Any help?? Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438933 Share on other sites More sharing options...
trq Posted January 14, 2008 Share Posted January 14, 2008 I'm not asking how long it's going to take... I just asked whether or not was possible. PHP has great string manipulation functionality so, yes it is possible. However, how easy it is going to be or how long its going to take to create is another question all together. Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438975 Share on other sites More sharing options...
Ken2k7 Posted January 14, 2008 Share Posted January 14, 2008 Wow...this topic can not be any more confusing. ??? I still have no idea how the conversion process works. Anyone except redfox180 know it? Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438977 Share on other sites More sharing options...
effigy Posted January 14, 2008 Share Posted January 14, 2008 The rules have already been defined by the software provider. There are about 15. Can you clearly state these as succinctly as possible? Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438985 Share on other sites More sharing options...
tinker Posted January 14, 2008 Share Posted January 14, 2008 yep, i've just spent a while reading this, yep sounds interesting little project, but it REALLY DOES NEED A RULESET, as stated there are 15 rules, but hey what are they? PHP is a programming language albeit the same as any other, so you can do almost anything any other programming language can, but if you don't know what your doing then PHP won't be much use. There again if x is here i'll go there and then if y is something i'll do that, and because of that i'll have do it again for some unknown reason, then to begger belief i'll add 42 to it and decide whether it needs a bit o'this or that, then just for good measure mix it all up just so that even I don't have the foggiest on a clear day, even though it's raining. Can anyone tell my why it can be sunny whilst it's raining? oh dear i've bungled it! Maybe from redfox's 1st and 3rd posts we could decipher a pattern, yet there's a whole lot more to it, so what's the point... just provide the ruleset please! Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438993 Share on other sites More sharing options...
Ken2k7 Posted January 14, 2008 Share Posted January 14, 2008 There again if x is here i'll go there and then if y is something i'll do that, and because of that i'll have do it again for some unknown reason, then to begger belief i'll add 42 to it and decide whether it needs a bit o'this or that, then just for good measure mix it all up just so that even I don't have the foggiest on a clear day, even though it's raining. Can anyone tell my why it can be sunny whilst it's raining? oh dear i've bungled it! Dear god, that's just as confusing as reading redfox's posts. Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-438995 Share on other sites More sharing options...
redfox180 Posted January 14, 2008 Author Share Posted January 14, 2008 just provide the ruleset please! I think there is a little confusion between what I call rules and entries. On the software I use there are rules to define how the system has to behave in different occasions. Then, there are entries, which are the fundaments on how to build a 'mask' which is nothing else then a compilation of 2/3/4 letters (called entry .There are about 180 just to file an invoice) followed by some text/data which is what will actually appear on the mask when filed. There is some software made by IBM which can do that but unfortunately for me not in the same computing language I am using. If you want I can write down all the entries but I don’t think it is going to solve the problem. Someone suggested using 'strings'...? It's not hard to write a mathematical expression to handle it but still I cannot see how to move from maths to php... Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-439108 Share on other sites More sharing options...
trq Posted January 14, 2008 Share Posted January 14, 2008 Based on your comments, I would say you have little hope of getting this done in php. Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-439227 Share on other sites More sharing options...
effigy Posted January 14, 2008 Share Posted January 14, 2008 What are the rules? Are there always 180 entries on an invoice? Is there only one type of invoice? Quote Link to comment https://forums.phpfreaks.com/topic/85836-text-filter/#findComment-439229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.