I am trying to implement some data filters on my text data. The filters are defined something like this:
(AND
(OR
AUTHOR=John PROFIT=90%
AUTHOR=Matt PROFIT=80%
)
PUBLISHER=OReilly
)
I need to somehow convert the above filter into something sensible so that I can apply to the following data:
Page 1
AUTHOR: John
PROFIT: 20%
PUBLISHER: TMH
BOOK: OPERATING SYSTEMS
Page 2
AUTHOR: John
PROFIT: 90%
PUBLISHER: OREILLY
BOOK: ALGORITHMS
Page 3
AUTHOR: Matt
PROFIT: 80%
PUBLISHER: TMH
BOOK: COMPUTER NETWORKS
Page 4
AUTHOR: Matt
PROFIT: 80%
PUBLISHER: OREILLY
BOOK: COMMUNICATION SYSTEMS
Then when I apply the filter to this data, I should get:
the results from Page 2 and Page 4. I thought of pushing the elements into an array as they are encountered while scanning the filter but it didn't make any sense because I'm not sure how to use this. Am I missing out some easy thing here?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.