-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parameterized macros #111
Comments
I think we need to parse to a proper AST to be able to do this. Since playing with and testing ASTs in C++ is a real real drag (really). I did a quick write-up in Haskell of a proposed AST format, and how variable substitution and macro calls could be applied: https://gist.github.com/3742284 @jelmervdl any comments? |
BTW, a sample invocation:
|
Looks ok to me. I don't really have anything to add. |
I thought a bit more about this, there are some annoyances in implementing this:
One solution, that simplifies things a bit is to move macro invocations out of the query using string interpolation a la Python. E.g.:
Another solution is string concatenation:
Though, I am still wondering if there is no off-the-shell solution that we can use... |
Consider these macros which will find all words that can occur as the OBJ1 of the verb DRINKEN:
obj1_drinken_lexical = """
( @rel="obj1" and
@word and
../node[@rel="hd" and
@lemma="drinken"]
)"""
obj1_drinken_phrase = """
( @rel="hd" and
../@rel="obj1" and
../../node[@rel="hd" and
@lemma="drinken"]
)"""
obj1_drinken_lexical_nonlocal = """
( (@cat or @word) and
%i% = //node[@rel="obj1" and
../node[@rel="hd" and
@lemma="drinken"]]/%i%
)"""
obj1_drinken_phrase_nonlocal = """
( @rel="hd" and
../%i% = //node[@rel="obj1" and
../node[@rel="hd" and
@lemma="drinken"]]/%i%
)"""
obj1_drinken = """
( %obj1_drinken_lexical%
or %obj1_drinken_phrase%
or %obj1_drinken_lexical_nonlocal%
or %obj1_drinken_phrase_nonlocal%
)
"""
If we want to do the same thing for "eten", we need another page of macros. I want to
be able to say
%dependent("obj1","drinken")%
and then define
dependent(Rel,Head) = """
( dependent_lexical(%Rel%,%Head%)
or dependent_phrase(%Rel%,%Head%)
or ....
etc
"""
The text was updated successfully, but these errors were encountered: