I'm trying to parse some text using PyParser. The problem is that I have names that can contain white spaces. So my input might look like this. First, a list of names:
Joe
bob
Jimmy X
grjiaer-rreaijgr Y
Then, things they do:
Joe A
bob B
Jimmy X C
the problem of course is that a thing they do can be the same as the end of the name:
Jimmy X X
grjiaer-rreaijgr Y Y
How can I create a parser for the action lines? The output of parsing Joe A
should be [Joe, A]
. The output of parsing Jimmy X C
should be [Jimmy X, C]
, of Jimmy X X
- [Jimmy X, X]
. That is, [name, action]
pairs.
If I create my name parser naively, meaning something like OneOrMore(RegEx("\S*"))
, then it will match the entire line giving me [Jimmy X X]
followed by a parsing error for not seeing an action (since it was already consumed by the name parser).
NOTE: Sorry for the ambiguous phrasing earlier that made this look like an NLP question.