Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6638671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:27:48+00:00 2026-05-25T23:27:48+00:00

I am trying to parse text using pyparsing. My function is shown below. Firstly,

  • 0

I am trying to parse text using pyparsing. My function is shown below. Firstly, I construct a list containing all the terms in my dictionary (a dictionary of commonly used terms in my website). Then I set my grammar to be this list of commonly used words. Then I construct the ZeroOrMore object with the grammar. Finally, I parse the string and I should get the matches found in my string. However, it throws a ParseException instead complaining that end of text was expected.

def map_dict_words(self, pbody):
        dict_terms = [term.term for term in Dictionary.objects()]
        look_for_these = oneOf(dict_terms, caseless=True).setResultsName("dict_words")
        parseobj = ZeroOrMore(look_for_these)
        matches = parseobj.parseString(pbody, parseAll=True)
        print matches

According to the FAQ in pyparsing’s homepage http://pyparsing-public.wikispaces.com/FAQs if I want the parser to parse the entire string I should either put StringEnd() in my grammar or use the optional arg parseAll=True. If I remove parseAll=True from my code it works but it doesn’t parse the entire string.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:27:48+00:00Added an answer on May 25, 2026 at 11:27 pm

    Think of pyparsing as a more advanced regular expression. When you pass it parseAll=True, it expects to match the entire string, qualifying each and every byte to some part of the grammar. Your grammar however only mentions some of the words that will appear in the string. You have to account for the rest of them somehow.

    In other words, assuming that popular words are “parrot”, “hovercraft”, “eels” and “fjords”, you have built an equivalent of the following regular expression:

    /^(?P<dict_words>eels|fjords|hovercraft|parrot)*$/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse some text using PyParser. The problem is that I have
I am trying to parse some text using boost. i have looked at the
I am trying to parse out sentences from a huge amount of text. using
I am trying to parse text for email id's using php / regex. Are
I'm trying to parse text-based file attachments (txt, doc, etc...). However, I can't seem
I am trying to parse some text and diagram it, like you would a
Trying to parse an HTML document and extract some elements (any links to text
I have a string: [\n['-','some text what\rcontains\nnewlines'],\n\n trying to parse: Regex.Split(@[\n['-','some text what contains
Im trying to parse the string located in /proc/stat in a linux filesystem using
I'm trying to parse an INI file using C++. Any tips on what is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.