hmCode/4
|
modifyHmCode/6 |
On input to hmCode/4, the ACode is partially instantiated by movement/5 from a single movement rule as follows:
Fs and X are the placeholders for the features of C-trace and the phrase itself, respectively.
LexC is the lexical category from the movement chain. Bs is a list of bindings [..,C(X),...] for each category in the movement chain. These bindings are necessary to link the computed pre- and post-condition goals to the elements.
For example, a C-trace may pop its features and the remote site must push the features for C.
Here we just compute the head adjunction(s) from the chain and call the necessary recovery routines for the non-lexical members of this chain.
%% hmCode(ACode,Pre,Post,Pre,Post) %% Local Remote %% Site SiteExamples of I/O:
Call: hmCode(trace(v,_368796,_368797,left),_368835,_368836,_368841,_368842) Exit: hmCode(trace(v,_368796,[v(_368859)],left), [popTr(v,_368796,es(i),es(o))], % PRE, LOCAL [], % POST, LOCAL [], % PRE, REMOTE [pushTr(_368859,es(i),es(o))]) % POST, REMOTE Call: hmCode(nontrace([v,agr],_368370,_368371),_368451,_368452,_368457,_368458) Exit: hmCode(nontrace([v,agr],v,[(lhs,_368502),agr(_368466),v(_368507)]), [], % PRE, LOCAL [mkEC(agr,_368465,_368466), % POST, LOCAL agr(_368479), mkFs([index(_368486),agm(_368479)],_368465), hAdj(_368507,_368466,_368502), addFeature(transparent(ecp),_368502), addFeature(dest(agr),_368507)], [], % PRE, REMOTE []) % POST, REMOTEThe following sub-sections documents what hmCode/4 does with the various ACode types.
[.. C..] C-trace |_______________| pushTr(X,..) popTr(C,Fs,..)X is [C ..], ACode becomes trace(C,Fs,[X],left)
hmCode(trace(C,Fs,[Var],left), [popTr(C,Fs,es(i),es(o))],[],[],[pushTr(X,es(i),es(o))]) :- Var =.. [C,X].
C-trace [.. C..] |_______________| nxtTr(C,Fs,,..) markedID(X)Looks in the input so
C
must be lexical. X
is [C..]
. ACode becomes
trace(C,Fs,[X],right)
.
hmCode(trace(C,Fs,[Var],right), [nxtTr(C,Fs,input(i))],[],[markedID(X)],[]) :- lexicallyRealized(C), !, % red Var =.. [C,X]. lexicallyRealized(C) :- lexicalCat(C), lexicon(_,C,_).
C-trace [.. C..] |_______________| nxt(LexC,Y,,..)|Conds' recover(C,X), popPTr(C,X,..) Post: pushPTr(C,Fs,..)Example is neg in English.
LexC
is obtained from a
moves_through
rule. Y
is
[LexC..]
. Conds'
comes from the
moves_through
rule, i.e. how to determine if
LexC
has moved through C
. For example, the
neg
feature on the verb.
hmCode(trace(C,Fs,[Var],right), [nxt(LexC,Y,input(i))|Condsp],[pushPTr(C,Fs,es(i),es(o))], [recover(C,X),popPTr(C,X,es(i),es(o))],[]) :- movesThroughRule(List,Conds), extractCatLabels(List,[LexC,C]), evalApplicable(Conds,Condsp), !, % red (findVar(List,LexC,Y) -> true ; true), Var =.. [C,X]. movesThroughRule([X,Y],CondsL) :- goal(rule(provided_iff(moves_through(X,Y),Conds))), listify(Conds,CondsL).
C-trace [.. C..] |_______________| recover(C,X) popPTr(C,X,..) Post: pushPTr(C,Fs,..)X is [C..].
hmCode(trace(C,Fs,[Var],right), [],[pushPTr(C,Fs,es(i),es(o))], [recover(C,X),popPTr(C,X,es(i),es(o))],[]) :- Var =.. [C,X].
nontrace([C1..,Cn],_,_)
Cn Local(dest of movement) Remote site Post: recovery + hdadj code + dest(Cn) if movement list > 1X is a lexical category in the movement list.
hmCode(nontrace(Is,X,Varsp),[],Code,[],[]) :- identifyLexCat(Is,X), recoverable(Is,Is,[],[],Vars,Code1), hdAdjunction(Is,Vars,Vars1,Code2), length(Is,L), (L>1 -> extractCatLabels(Is,Cs), last(Cs,C), Var =.. [X,R], union([Var],Vars1,Varsp), append1(Code2,[addFeature(dest(C),R)],Code3) ; Varsp = Vars1, Code3 = Code2), append1(Code1,Code3,Code). identifyLexCat(Cs,C) :- (member(C,Cs), lexicalCat(C)) -> true ; C = [].Code for computing the recovery elements.
%% recoverable(List,List,[],[],Vars,Code) holds if a list of category %% labels to appear at a node is recoverable from the input. %% If so, then %% Code: Prolog code to recover the constituents %% Vars: List of bindings of the form ..C(V).. %% C: category label, V: name of variable used in Code recoverable([],_,Vars,Code,Vars,Code). recoverable([C|L],Cs,Vars,Code,Varsp,Codep) :- assocRealCategory(C,DerivC,Vars1,Code1), ( member(DerivC,Cs) ; C == DerivC ), % independently recoverable union(Vars,Vars1,Vars2), append(Code,Code1,Code2), !, recoverable(L,Cs,Vars2,Code2,Varsp,Codep). % assocRealCategory(X,Y,S,L) % % Given a category X, determine a real category Y that X can be synthesized % from (usually X). % L = List of goals necessary for synthesizing X from Y % S = List of variable substitutions (c(Var)) % % Three (not necessarily mutually exclusive) cases, C is a: % (1) Lexical category: look for C. % (2) Bundle of features derived from a category C' using Gs: look for C'. % rule C derived_from C' provided Gs % (3) Non-trace null EC: look for C. % rule empty C with Fs st GsComputes head adjunction code:
% Given movement sequence [C1,..,Cn] % produces hdAdjSeq([X1,..,Xn],LHS) % where Vars = [..,Ci(Xi),..] % Output adjunct structure LHS is added to Vars hdAdjunction(Chain,Vars,[lhs(LHS)|Varsp],Goals) :- length(Chain,N), N>1, !, extractCatLabels(Chain,Cs), mapVars(Cs,Vars,NVars,Xs), hdAdjunctionGoals(Cs,Xs,LHS,Goals), append(Vars,NVars,Varsp). hdAdjunction(_,Vars,Vars,[]).
Produces: mod(Dest,[C(X)],Pre,Post)
Dest is the category of the destination of the movement rule. Pre and Post are the conditions computed by hmCode/4 for ACode = trace(_,_,_,_).
modifyHmCode(Pre,Post,ACode,Dest,Mods,Modsp) :- (Pre=[],Post=[]) -> Mods = Modsp ; (ACode = trace(_,_,Vars,_) -> Mods = [mod(Dest,Vars,Pre,Post)|Modsp] ; printNotice('Error: Head movement compilation, modifyHmCode/6'), fail).