searching in paragraphs.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Archanak
    New Member
    • Sep 2006
    • 79

    searching in paragraphs.

    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
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    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.

    Comment

    • Archanak
      New Member
      • Sep 2006
      • 79

      #3
      Originally posted by KevinADC
      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

      Comment

      • eWish
        Recognized Expert Contributor
        • Jul 2007
        • 973

        #4
        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

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          Originally posted by Archanak
          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.

          Comment

          Working...