Fork me on GitHub
#instaparse
<
2016-04-12
>
ska09:04:36

What kind of combination are you thinking about, @conaw ?

ska09:04:04

Oh, and regarding your string question, I did something similar with finding regexps in a query language which would be enclosed by slashes and allowed backslash-escaped slashed inside. The regexp for this was so weird, I completely forgot, how it worked, but here it is:

REGEXP = <'/'> #'(?:.(?!(?<![\\\\])/))+.?' <'/'>
(the grammar is defined in a Clojure string, thus the massive escaping)

conaw09:04:55

not sure yet to be honest — I’d like to be doing POS tagging, and tokenizing, but really enjoying instaparse and curious if anyone has used it in conjunction with something like opennlp

ska09:04:00

I once did a workshop on Clojure with very basic NLP examples (it was at a faculty for computational linguistics), but I did not combine it with any existing NLP libraries. Here at work, the NLP stuff is mostly self-written as much of it predates the open source libs. And we do not (yet?) use Clojure in that area.

ska09:04:19

Hm, looks like I never polished that workshop to put it online somewhere. Sorry.

ska09:04:56

(enough boasting now; please excuse the self-plugging)

conaw09:04:51

Not boasting at all, I appreciate the link.

conaw09:04:24

Another thing — Is there an idiomatic way to get the matched portion of a string for a given portion of a parse into the final transformed clojure data

conaw09:04:56

I’m trying to parse the same text multiple times iteratively — passing the result to a different more granular parser based on the first

conaw09:04:16

basically I’m trying to split the text up using a parse

conaw09:04:52

spans looks like

ska11:04:02

There is a :partial option but it only returns the parse tree as far as it could be parsed. Maybe the total mode would help? Can't say. Sorry.

ska14:04:07

@conaw, I just found the span function which takes a parse tree (result of parsing) and returns start and end index into the string. So, you could first parse partially and then as your input string for the covered substring.

ska14:04:38

Like this:

(let [s "abcd"
               g "Q='a' 'b'"
               p (i/parser g)
               t (p s :partial true)]
               (apply subs
                             (into [s] (i/span t))))

ska14:04:32

(sorry for the broken indentation)