Skip to content
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

Nested Rules (#34) #107

Merged
merged 40 commits into from
Mar 4, 2023
Merged

Nested Rules (#34) #107

merged 40 commits into from
Mar 4, 2023

Conversation

mr-martian
Copy link
Collaborator

@mr-martian mr-martian commented Nov 10, 2022

This PR adds WITH rules, which are followed by a list of rules in {}, where the latter rules are only run if the WITH matches. These rules will be run with the same values of _TARGET_ and _MARK_ as FIND.

WITH (det def) IF (1X (n)) {
  MAP (@det) (*) ;
  SETPARENT (*) TO (1 _MARK_) ;
  SETCHILD (*) TO (-1 (predet)) ;
} ;

closes #18
closes #34
relevant to #45 and #103

@mr-martian
Copy link
Collaborator Author

note to self: I think in the refactoring process I lost the lines that let A change the rule target and that's probably behind a lot of the test failures.

@mr-martian
Copy link
Collaborator Author

I've changed the syntax, so the example above is

FIND (det def) IF (1X (n)) {
  MAP (@det) (*) ;
  SETPARENT (*) TO (1 _MARK_) ;
  SETCHILD (*) TO (-1 (predet)) ;
} ;

@mr-martian mr-martian marked this pull request as ready for review February 23, 2023 23:09
@mr-martian
Copy link
Collaborator Author

helps with #103
helps with #45
closes #34
closes #18 (probably)

@mr-martian
Copy link
Collaborator Author

FIND definitely could share unifications and regexes with its subrules, but I don't feel like wading into the semantics of that atm.

@TinoDidriksen
Copy link
Member

Any attachment to FIND? I prefer WITH, because it reads as English. "With <these cohorts> do { <these rules> }".

@TinoDidriksen
Copy link
Member

Segfault where context_stack.back().attach_to.cohort is null in.

Input:

"<LU>"
	"LU" <DAB:og> <DA:og> <2> <der> KC @CO #1->3
"<jeg>"
	"jeg" <DA:jeg> <insert> PERS 1S @SUBJ> #2->3
"<ikititerpakka>"
	"ikitippaa" <DAB:hente=OBJ=ind> <DA:henter> <7> <changed> <TIP+vv> <vder> <FST:iki·TIP·vv·TIR·vv·V·Ind·1Sg·3PlO> <B:ikititerpaa> <TV> <ex-iiv> <i> <mv> <btv> <hv> <nosubj> <tr> <subjH> V 3PO PR IND 1S @PRED #3->0
"<OBJ>"
	"OBJ" <DA:OBJ> <inc> PART @<OBJ #4->3
"<OBJ=ind>"
	"OBJ=ind" <DA:ind> <inc> PART @MV< #5->3
"<dem>"
	"de" <DA:dem> <insert> PERS 3P @<OBJ #6->3
"<TIR>"
	"TIR+vv" <DAB:efterhånden> <DA:efterhånden> <right> <8> <adv> <der> <TV> <nosubj> <subjH> ADV IND @<ADVL #7->3
"<da>"
	"da" <DA:da> <insert> KS @SUB #8->10
"<jeg>"
	"jeg" <DA:jeg> <insert> PERS 1S @SUBJ> #9->10
"<nassaaramalu>"
	"nassaarpoq" <DAB:finde=noget> <DA:finder> <1> <fn:discover> <aa:t0> <t0> <vt> <HTR> <changed> <FST:nassaar·V·Cau·1Sg·LU> <B:nassaarpoq> <longda> <HV> <©HV> <IV> <Conj-encl> <first-word> <i> <pseudo-i> <biv> <tam> <vOn> <mv> <hv> <left> <nosubj> <itr> <subjH> <vH> V PR CAU 1S @CAU #10->3
"<noget>"
	"noget" <DA:noget> <inc> PART @MV< #11->10
"<efter=først=at=have>"
	"efter=først=at=have" <DA:efter=først=at=have> <insert> X @X #12->13
"<ilioraariarlunga>"
	"ilioraavoq" <DAB:anbringe> <DA:anbragt> <left> <5> <fn:add> <aa:t1> <fn:institutionalize> <aa:t0> <vH> <vt> <vta+LOC> <fn:put_spatial> <HTR> <changed> <HTR+vv> <vder> <FST:iliorar·HTR·vv·RIAR·vv·V·Cont·1Sg> <B:ilioraariarpoq> <IV> <ex-iiv> <i> <vOh> <vOn> <mv> <biv> <hv> <nosubj> <subjH> <subjH> <vH> V PCP2 AKT 1S @CL-ADVL> #13->3
"<RIAR>"
	"RIAR+vv" <DAB:nil> <DA:nil> <right> <6> <adv> <der> <IV> <tam> <nosubj> <subjH> <ex-v> ADV CONT 1S @<ADVL #14->13
"<sumut>"
	"suna" <DAB:nil> <DA:nil> <mwe-prepart> <3> <interr> <FST:suna·Pron·Trm·Sg> <Int> PRON S @X #15->16
"<tamaanga>"
	"ma" <DAB:alle=vegne=hen> <DA:alle=vegne=hen> <left> <4> <aloc> <dei> <adir> <FST:ma·Adv·Trm> <TA> <dem> <mwe-core> ADV TRM @ADVL> #16->13
"<$.>"
	"." <DAB:.> <DA:.> <9> <clb> PU @PU #17->0

Grammar:

DELIMITERS = "<$.>" ;

MOVE WITHCHILD (*) (<left> @CAU) (NEGATE p (IMP)) BEFORE WITHCHILD (*) - (CONJ @CO) (pl (<mv>) OR (<hv>) LINK *Sp (<hv>)) ;

@mr-martian
Copy link
Collaborator Author

the segfault, as with so many other errors I had to fix, was overly-aggressive search-and-replace at the beginning of the process.

@TinoDidriksen TinoDidriksen changed the base branch from main to multi March 4, 2023 21:19
@TinoDidriksen TinoDidriksen merged commit 9f01770 into GrammarSoft:multi Mar 4, 2023
TinoDidriksen pushed a commit that referenced this pull request Mar 4, 2023
* Nested rules (issue #103, closes #34, closes #45)
* Refactored rule processing (WIP issue #18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use rule action callbacks instead of return Multiple rules per match
2 participants