Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Converting words to numbers with HOP::Parser

by Ovid (Cardinal)
on Nov 06, 2005 at 19:55 UTC ( #506147=note: print w/replies, xml ) Need Help??


in reply to Re: Converting words to numbers with HOP::Parser
in thread Converting words to numbers with HOP::Parser

I missed that module when I was searching for it on the CPAN. Bummer.

I find it interesting what extremely different styles our solutions have. Your's is quite procedural. Using a parser is declarative. What I find interesting about the latter is how one can pretty much rearrange all of the declarative portions of the parser and things still work as intended. This gives one a lot of flexibility.

It's also (relatively) easy to extend. If I want to turn it into a calculator which responds appropriately to "divide three by seven and add twelve point two", I can do that. Further, it would merely build on what's there and nothing else would need to be touched. I wonder how feasible this is with a procedural model.

In any event, your speculation was correct. My post was primarily intended to show off the power of the HOP::Parser as opposed to "hey, let's turn words into numbers!"

Cheers,
Ovid

New address of my CGI Course.

  • Comment on Re^2: Converting words to numbers with HOP::Parser

Replies are listed 'Best First'.
Re^3: Converting words to numbers with HOP::Parser
by eric256 (Parson) on Nov 06, 2005 at 23:27 UTC

    Well with a quick regex you should be able to just grab out portions of text that it will be able to match to numbers. Then you could turn something like "divide three by seven and add twelve point two" into "divide 3 by 7 and 12.2", then you just have to manage the new portions. Frankly the parser version makes no sense at all to me and I have no idea what it is doing at all. A quick (realy quick) explanation might go along way for those of us who haven't read HOP, though I get more and more curious about HOP as these posts come out.


    ___________
    Eric Hodges $_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9'; s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://506147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2020-11-24 18:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?