Replies: 1 comment
-
I would recommend processing a data frame at a time, rather than trying to have all the frames processed together, incrementally re-parsing only whats needed as more data is added. This makes it so You could go a step further. The parsers have slightly different behavior when operating on potentially partial data and this can lead to surprising behavior. You have an unambiguous end-of-frame token, |
Beta Was this translation helpful? Give feedback.
-
Hi again!
I'm facing a problem I'm not sure how to solve with winnow. In libraries like Haskell's
attoparsec
and Scala'satto
, I can take an existing parsing result, and if it is partial, I can feed it more data, thus getting a new result (success, partial, or failure), ad infinitum.Here's an example of the language I'm parsing:
I split the segments into lines for readability, but they come as one long string with
" ; "
being a separator.The input comes from a pre-trained language model, token-by-token, a token being any string.
As the input doesn't have a clear end (I could always add more segments), my parsing result is always
Incomplete
.If I mark the stream with
.complete()
, then I get the parsing result as expected, so I know the parsers are working correctly.My problem is that I don't know how to say in winnow: "Assume the input you have parsed so far is complete. Is the result a success or a failure?"
I tried using
.complete_err()
, but since my parser always returnIncomplete
, I'll always get back an error, even the parsed input so far makes a valid result.Is there any way to achieve what I'm trying to do?
I'm not sure I managed to explain the problem well enough, so feel free to ask clarifying questions 😃
Thanks! 🙏
P.S.
It took a bit of trial and error and some lifetime annotations, but I must say that working with winnow is pretty fun. And the
debug
feature flag is a life-saver!Beta Was this translation helpful? Give feedback.
All reactions