By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,845 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,845 IT Pros & Developers. It's quick & easy.

searching in paragraphs.

P: 79
Hi,

I have a paragraph.

my search words are in parenthesis (grouped together).

for eq:- apple AND (mango OR orange)

It should retrieve the sentences which has apple (is a must word) along with it mango or orange has to be present.

2) (apple AND (mango OR orange) OR (pineapple AND pine)) AND potato.

same way apple has to be present along with that mango or orange or pineapple AND pine (either of them) can be present with that grouping potato has to present.

I am not able search for multiple parenthesis and groupings of words.

How should i process such query terms.

How should i search and retrieve the sentences?


with regards
Archana
Jan 11 '08 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
Perl has no way of knowing what any of that means. Have you written some sort of custom parsing code to first parse all that search stuff into something perl can understand? Or is that the queries for searching a database? If so, maybe you posted in the wrong forum.
Jan 11 '08 #2

P: 79
Perl has no way of knowing what any of that means. Have you written some sort of custom parsing code to first parse all that search stuff into something perl can understand? Or is that the queries for searching a database? If so, maybe you posted in the wrong forum.
Hi,

what exacly i need to parse this expression.

Its something like the user gives his term/query with boolean combaination which includes nesting of words with paranthesis for eg . dog AND (cat OR (cow))
like this which basically had to split terms and search the paragraph.

The results would be the lines that has dog has a mandatory word either of cat or cow has to be present .

A kind of expression parser of boolean terms with paranthesis in perl .

How to do ?

with regards
Archana
Jan 12 '08 #3

eWish
Expert 100+
P: 971
I am not sure if this will help you or not. But I would have a look at the Search::Tools module at CPAN.

--Kevin
Jan 12 '08 #4

KevinADC
Expert 2.5K+
P: 4,059
Hi,

what exacly i need to parse this expression.

Its something like the user gives his term/query with boolean combaination which includes nesting of words with paranthesis for eg . dog AND (cat OR (cow))
like this which basically had to split terms and search the paragraph.

The results would be the lines that has dog has a mandatory word either of cat or cow has to be present .

A kind of expression parser of boolean terms with paranthesis in perl .

How to do ?

with regards
Archana

If you want to code it yourself you will definetly have to use some regular expressions. This will not be too easy, you will have to do a lot of syntax checking to make sure the queries are well formed. If the users can enter nearly anything for the search terms you will probably have to build a complex data structure to break it all into it's various parts then reassemble them into regular expressions and then search the text.

Some of how you do this will depend on how you allow the user to input the queries. The more control the user has in writing the queries, the harder it will be for you to code. The less control the user has, the easier it should be to code.
Jan 12 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.