text
stringlengths
22
301k
@NODES _ROOT @POST excise(1,6); noop(); @RULES _xNIL <- http ### (1) _xWILD [plus fails=(\t)] ### (2) \t ### (3) RID ### (4) _xNUM ### (5) \n [opt] ### (6) @@
# Add an empty attribute named "an attribute" to the concept named "a concept" @CODE G("myConcept") = makeconcept(findroot(),"a concept"); G("myAttr") = addattr(G("myConcept"),"an attribute"); "output.txt" << attrname(G("myAttr")) << "\n";
@NODES _LINE @RULES _ordinal <- _xNUM [s] _xWILD [s one t match=(st nd rd th)] @@
@CODE # Uncomment when analyzer is complete # DisplayKB(G("pred_codes"),1); DisplayKB(G("note_words"),1); DisplayKB(G("pred_codes"),1); #Save preds to csv L("name") = "_preds"; L("filepath") = G("$inputhead") + L("name") + ".csv"; L("header") = "code, max, sum, mean\n" L("filepath") << L("header"); L("iter") = down(G("pred_codes")); while (L("iter")) { L("row") = conceptname(L("iter")) + ","; L("max_val") = attrvals(findattr(L("iter"), "max")); L("max") = getsval(L("max_val")); L("sum_val") = attrvals(findattr(L("iter"), "sum")); L("sum") = getsval(L("sum_val")); L("mean_val") = attrvals(findattr(L("iter"), "mean")); L("mean") = getsval(L("mean_val")); L("row") = L("row") + L("max") + "," + L("sum") + "," + L("mean") + "\n"; L("filepath") << L("row"); L("iter") = next(L("iter")); } # Repeat above, but transposed and without headers. # Output should be of the form hadm,code1_pred,code2_pred,...,code50_pred # HADM ID should be head/base of input file L("hadm") = G("$inputhead"); "max_preds.csv" << L("hadm"); "sum_preds.csv" << L("hadm"); "mean_preds.csv" << L("hadm"); # Iterate over all codes in split. Order is important. L("iter") = down(G("code_to_euis")); while (L("iter")) { # Get icd code name L("code") = conceptname(L("iter")); # Look up code concept in preds. If NULL, append 0.0 to row. L("pred_con") = findconcept(G("pred_codes"), L("code")); if (!L("pred_con")) { "max_preds.csv" << ",0.0"; "sum_preds.csv" << ",0.0"; "mean_preds.csv" << ",0.0"; } else { L("max_val") = attrvals(findattr(L("pred_con"), "max")); L("max") = getsval(L("max_val")); "max_preds.csv" << "," << L("max"); L("sum_val") = attrvals(findattr(L("pred_con"), "sum")); L("sum") = getsval(L("sum_val")); "sum_preds.csv" << "," << L("sum"); L("mean_val") = attrvals(findattr(L("pred_con"), "mean")); L("mean") = getsval(L("mean_val")); "mean_preds.csv" << "," << L("mean"); } L("iter") = next(L("iter")); } @@CODE
# Given an array (multi-valued variable) of KB concepts, sort the concepts by the given attribute. numeric_b = 1 if num, 0 if string type attribute. descending_b = 1 if descending order, 0 if ascending. E.g., G("sorted") = sortconsbyattr(G("cons"),"count",1,0); will sort an array of KB concepts by their "count" attribute in ascending order, assigning a new sorted array to G("sorted"). The given array in G("cons") is left unaltered. L("return_arr") = sortconsbyattr(L("arr_c"), L("attr_s"), L("numeric_b"), L("descending_b"));
# Match a minimum of 1 up to any number of nodes. Matches indefinitely repeating element @RULES _nouns <- _noun [plus] @@
@DECL ############## ## FN: XMLHEADER ## SUBJ: Print header tags for XML file. ## RET: None. ############## xmlheader( L("out") # Output stream. ) { L("out") << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" << "\n"; } ############## ## FN: XMLSTART ## SUBJ: Print a start XML tag. ## RET: None. ############## xmlstart( L("tag"), # Tag name to use. L("out") # Output stream. ) { L("out") << "<" << L("tag") << ">\n"; } ############## ## FN: XMLEND ## SUBJ: Print an end XML tag. ## RET: None. ############## xmlend( L("tag"), # Tag name to use. L("out") # Output stream. ) { L("out") << "</" << L("tag") << ">\n"; } ############## ## FN: XMLSHORT ## SUBJ: Print a one-liner XML tag. ## RET: None. ############## xmlshort( L("tag"), # Tag name to use. L("val"), # Value to output. L("out") # Output stream. ) { L("out") << "<" << L("tag") << ">" << L("val") << "</" << L("tag") << ">" << "\n"; }
@CODE DictionaryEnd(); # DisplayKB(findroot(),0); @@CODE
@NODES _LINE @RULES # Ex: contracted _verb <- contracted [s] @@ # Ex: contract _verb <- contract [s] @@ # Ex: wrote _verb <- wrote [s] @@ # Ex: write _verb <- write [s] @@ # Ex: designed _verb <- designed [s] @@ # Ex: design _verb <- design [s] @@ # Ex: implemented _verb <- implemented [s] @@ # Ex: implement _verb <- implement [s] @@ # Ex: sold _verb <- sold [s] @@ # Ex: well _verb <- well [s] @@ # Ex: programmed _verb <- programmed [s] @@ # Ex: program _verb <- program [s] @@ # Ex: seek _verb <- seek [s] @@ # Ex: seeking _verb <- seeking [s] @@
# hello tokenize nil # Gen: Convert input to token list. nlp kb # comment nlp tags # comment nlp items # comment nlp count # comment nlp names # comment nlp output # comment
# Exit from the current pass file immediately, without performing rule matching (if any) @CODE exitpass(); # Exit the current pass file immediately. @@CODE
@NODES _LINE @PRE <1,1> length(3); <5,5> length(3); @RULES # Ex: www.absoluterealtime.com _url <- www [s layer=("_machineName")] \. [s] _xALPHA [s layer=("_companyName")] \. [s] _xWILD [min=1 max=1 s layer=("_domainName") match=("com")] @@
@NODES _ROOT @POST "zap.txt" << N("$text") << "\n"; excise(1,1); @RULES _xNIL <- _xWILD [one match=(_beginEnum _endEnum _itemMarker _COMMENT _spacing)] ### (1) @@
@NODES _ROOT @RULES _header <- _xWILD [one matches=(\[)] ### (1) _xWILD _xWILD [one matches=(DATE)] \: _xWILD _xWILD [one matches=(\n \r)] ### (6) @@
@PATH _ROOT _posZone _defZone _definition _headerZone _LINE @POST X("con",6) = MakeCountCon(X("con",3),"explanation"); @RULES _xNIL <- _item ### (1) @@
@PATH _ROOT _LINE _language @POST addstrval(X("con",2),"language",N("$text",1)); single(); @RULES _lang <- _xWILD [plus fail=(\, _xEND)] @@
@PATH _ROOT _AttlistDecl @POST S("buffer1") = str(N("$text",2)) ; S("buffer2") = str(N("$text",3)) ; if (N("$text",2) && N("$text",3)) { S("AttributeName") = S("buffer1") + S("buffer2") ; } else if (N("$text",2)) S("AttributeName") = S("buffer1") ; else if (N("$text",3)) S("AttributeName") = S("buffer2") ; S("AttribType") = S("AttributeName") + "Type" ; G("currentConcept") = findconcept(G("Elements"),X("ElementName",2)); G("currentattr") = findattr(G("currentConcept"),S("AttributeName")) ; addattr(G("currentConcept"),S("AttributeName")) ; addstrval(G("currentConcept"),S("AttributeName"),N("$text",7)) ; addattr(G("currentConcept"),S("AttribType")) ; addstrval(G("currentConcept"),S("AttribType"),N("$text",5)) ; single() ; @@POST @RULES _AttDef <- _whiteSpace [opt] ### (1) _xWILD [s one matches=("_xALPHA" "_" ":")] ### (2) _xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3) _whiteSpace [opt] ### (4) _AttType [one] ### (5) _whiteSpace [opt] ### (6) _DefaultDecl [one] ### (7) @@ @@RULES
@NODES _timeZone @POST L("timezone") = getconcept(G("state"),"timezone"); makeconcept(L("timezone"),N("$text")); @RULES _xNIL <- _xWILD [plus fail=(\,)] ### (1) @@
@NODES _termEntry @POST X("entry") = N("$text", 4); @RULES _xNIL <- entry ### (1) \= ### (2) E ### (3) _xNUM ### (4) _xWILD [one matches=(\n \r)] ### (5) @@
@PATH _ROOT _contactZone # @INI # Restart count in each zone here. # X("nlines") = 0; # @@INI @POST N("lineno",1) = ++X("nlines"); N("format below",1) = "true"; @RULES _xNIL <- _LINE _xWILD [s one lookahead match=(_BLANKLINE _horizRule)] @@ @POST N("format above",2) = "true"; @RULES _xNIL <- _xWILD [s one match=(_BLANKLINE _horizRule)] _LINE [lookahead] @@ # No blank or other formatting line above or below. @POST N("lineno",1) = ++X("nlines"); @RULES _xNIL <- _LINE @@
@PATH _ROOT _group _subgroup _LINE @POST if (X("con",4)) addstrval(X("con",4),"hex",N("$text",1)); @RULES _xNIL <-_hex @@ @POST if (X("con",4)) addstrval(X("con",4),"type",N("type",1)); @RULES _xNIL <-_qualified @@
@CODE L("hello") = 0; if (!G("semantic processing")) exitpass(); @@CODE #@PATH _ROOT _TEXTZONE _sent _clause @NODES _clause #@CHECK # if (!N("ne") && !N("ne arr")) # fail(); @POST if (N("sem texts")) X("sem texts") = N("sem texts"); if (N("ne") || N("ne arr")) L("obj") = domobjectregister(N(1),X()); @RULES _xNIL <- _np @@ #@CHECK # if (!N("ne") && !N("ne arr")) # fail(); @POST if (N("sem vals")) X("sem vals") = N("sem vals"); if (N("ne") || N("ne arr")) L("entity") = domentityregister(N(1),X()); @RULES _xNIL <- _xWILD [one match=( _advl _adv )] @@
@CODE L("hello") = 0; @@CODE
@NODES _ROOT @RULES _xNIL <- _xWILD ### (1 @@
@CODE if (G("$islastfile") || !G("$isdirrun")) { # Loop through states KB and make states dict file L("state") = down(G("states")); while (L("state")) { G("dict") << conceptname(L("state")) << " s=state"; L("attr") = down(L("state")); while (L("attr")) { L("name") = conceptname(L("attr")); if (L("name") == "abbrev") { G("dict") << " abbrev=" << QuoteIfNeeded(strval(L("attr"),"letters")); } L("attr") = next(L("attr")); } L("state") = next(L("state")); G("dict") << "\n"; } SaveKB(G("kbb"),G("states"),2); } closefile(G("dict")); closefile(G("kbb")); closefile(G("abbrev")); closefile(G("cities")); closefile(G("debug")); @@CODE
@PATH _ROOT _experienceZone _experienceInstance _LINE _Caps @POST X("job title",3) = N("$text",1); X("company name",3) = N("$text",5); single(); @RULES _xNIL <- _jobTitle [s] _xWHITE [s] at [s] _xWHITE [s] _Caps [s] @@
# Match if the element is in a match list. Matches is a restricted wildcard and succeeds only if one of the list names matches a node @RULES _james <- _xWILD [matches=(jim jimmy james) singlet min=1 max=1] @@
@CODE L("hello") = 0; @@CODE @NODES _sent @CHECK if (!N("verb",2)) fail(); @POST L("tmp2") = N(2); group(2,2,"_verb"); L("v") = N(2); pncopyvars(L("tmp2"),N(2)); group(2,2,"_vg"); mhbv(N(2),L("neg"),0,0,0,0,L("v")); pncopyvars(L("tmp2"),N(2)); N("voice",2) = "active"; clearpos(N(2),1,0); # Zero out token info. @RULES _xNIL <- _xSTART _xALPHA _proObj [s lookahead] @@ # np and np @POST if (pnname(N(5)) == "_vg") if (!N("voice",5)) N("voice",5) = "active"; group(2,4,"_np"); N("compound-np",2) = 1; @RULES _xNIL <- _xSTART _np _conj _np _xWILD [one lookahead match=(_adv _advl _vg)] @@ # np of np and np @POST group(3,5,"_np"); @RULES _xNIL <- _np of [s] _np _conj _np _xWILD [one lookahead match=(_vg)] @@ # np of np @POST group(1,3,"_np"); @RULES _xNIL <- _np of [s] _xWILD [one match=(_np _np)] @@ # after np vg @CHECK L("n") = pndown(N(1)); if (strtolower(pnname(L("n"))) != "after") fail(); @POST group(1,1,"_fnword"); @RULES _xNIL <- _prep _np _xWILD [one lookahead match=(_vg)] @@ # states, " ... @POST L("tmp1") = N(1); group(1,1,"_verb"); L("v") = N(1); pncopyvars(L("tmp1"),N(1)); group(1,1,"_vg"); mhbv(N(1),L("neg"),0,0,0,0,L("v")); pncopyvars(L("tmp1"),N(1)); N("voice",1) = "active"; clearpos(N(1),1,0); # Zero out token info. @RULES _xNIL <- _xWILD [one match=(say said says state stated states quip quips quipped recalls recalled)] \, [s lookahead opt] \" @@ # Some embedded/relative clause handling. # np vg np vg @CHECK if (N("voice",5)) # If verb resolved... fail(); if (N("pattern",5) != "vg-to-vg") fail(); # Else, no way to be passive voice. if (N("glom",5) == "left" || N("glom",7) == "right") fail(); # If inf or -ing, can't resolve with this verb lookahead. if (!N("noninf",9) || N("-ing",9)) fail(); # Make sure first verb in vg can be -en conjugation. S("ven") = findven(N(5)); if (!S("ven")) fail(); # Error. @POST # Set passive conjugation. pnreplaceval(S("ven"),"-en",1); if (!N("voice",5)) N("voice",5) = "passive"; group(5,7,"_clause"); setunsealed(5,"true"); # 07/10/12 AM. group(5,5,"_advl"); setunsealed(5,"true"); # 07/10/12 AM. @RULES _xNIL <- _xWILD [one match=(_xSTART _clause)] _xWILD [star match=(_adv _advl)] _np _xWILD [star match=(_adv _advl)] _vg _xWILD [star match=(_adv _advl)] _np _xWILD [star lookahead match=(_adv _advl)] _vg @@ # Else, clause the first verb. # 2nd should be passive... # np vg np vg # WEAK RULE. # @PRE <5,5> varne("voice","passive"); @CHECK # Make sure first verb in vg can be -en conjugation. S("ven") = findven(N(9)); if (!S("ven")) fail(); @POST if (N("glom",5) == "left") # 04/21/07 AM. { group(2,5,"_clause"); # 04/21/07 AM. setunsealed(2,"true"); # 07/10/12 AM. } else { # Set passive conjugation. pnreplaceval(S("ven"),"-en",1); N("voice",9) = "passive"; if (!N("voice",5)) N("voice",5) = "passive"; group(2,8,"_clause"); setunsealed(2,"true"); # 07/10/12 AM. } @RULES _xNIL <- _xSTART _xWILD [star match=(_adv _advl)] _np _xWILD [star match=(_adv _advl)] _vg _xWILD [star match=(_adv _advl)] _np _xWILD [star match=(_adv _advl)] _vg [lookahead] @@ # prep np np # prep np date @CHECK if (N("sem",4) != "date") fail(); @POST L("tmp4") = N(4); group(4,4,"_advl"); pncopyvars(L("tmp4"),N(4)); clearpos(N(4),1,0); @RULES _xNIL <- _prep _np _xWILD [star match=(_advl _adv)] _np @@ # prep np @POST pncopyvars(3); if (S("ne")) S("ne") = 0; S("prep") = N(1); S("pp") = 1; if (strtolower(N("$text",1)) == "by") { S("by-np") = 1; if (N("sem",3) != "date" && N("sem",3) != "geoloc") S("by-actor") = 1; # 04/21/07 AM. } sclearpos(1,0); singler(1,3); @RULES _advl <- # _xWILD [s one match=(_prep) except=(to)] _xWILD [one match=(_prep)] _adv [star] _xWILD [s one match=(_np) except=(_proSubj)] _xWILD [one lookahead fail=(_conj)] @@ # , advl , # , adv , @POST pncopyvars(2); sclearpos(1,0); single(); @RULES _advl <- \, [s] _xWILD [one match=(_adv _advl)] \, [s] @@ # vg advl vg # vg by-np vg @CHECK if (!N("by-np",2)) fail(); @POST L("v") = N("verb node",1); if (L("v")) fixverb(L("v"),"passive",0); if (!N("voice",1)) N("voice",1) = "passive"; S("passive") = 1; singler(1,2); @RULES _clause [unsealed] <- _vg _advl _vg [lookahead] @@ # parallel construction. # vg np conj vg @CHECK S("v1") = N("verb node",1); if (!S("v1")) fail(); S("v7") = N("verb node",7); if (!S("v7")) fail(); if (pnvar(S("v7"),"mypos")) fail(); S("pos1") = pnvar(S("v1"),"mypos"); if (!S("pos1")) fail(); S("pos") = vtreebanktopos(S("pos1")); if (!vconjq(S("v7"),S("pos"))) fail(); @POST N("qsent50 vncv",7) = 1; if (N("voice",1) && !N("voice",7)) L("voice") = N("voice",1); else L("voice") = N("voice",7); fixvg(N(7),L("voice"),S("pos1")); @RULES _xNIL <- _vg _xWILD [star lookahead match=(_adv _advl)] _np [opt] _xWILD [star match=(_adv _advl)] _conj _xWILD [star match=(_adv _advl)] _vg @@ # Appositive. # than np , np , vg @POST fixvg(N(6),0,0); group(2,4,"_np"); @RULES _xNIL <- than [s] _np \, _np \, _vg @@ # np, np and np, vg # complex appositive. # note that it competes with an np list. @POST group(4,6,"_np"); group(2,5,"_np"); N("apposition",2) = 1; @RULES _xNIL <- _xSTART ### (1) _np ### (2) \, ### (3) _np ### (4) _conj ### (5) _np ### (6) \, ### (7) _xWILD [one lookahead match=(_vg)] ### (8) @@ # simple appositive. @CHECK if (N("mypos",2) != "NP" && N("mypos",4) != "NP") fail(); @POST group(2,5,"_np"); N("apposition",2) = 1; @RULES _xNIL <- _xWILD [one match=(_xSTART)] _np \, _np \, @@ # ^ np , np that vg np , # appositive "clause". # @POST group(2,15,"_np"); N("apposition",2) = 1; @RULES _xNIL <- _xSTART ### (1) _xWILD [star match=(_advl _adv)] ### (2) _np ### (3) _xWILD [star match=(_advl _adv)] ### (4) \, ### (5) _xWILD [star match=(_advl _adv)] ### (6) _np ### (7) _xWILD [star match=(_advl _adv)] ### (8) _xWILD [s one match=(that which)] ### (9) _xWILD [star match=(_advl _adv)] ### (10) _vg ### (11) _xWILD [star match=(_advl _adv)] ### (12) _np ### (13) _xWILD [star match=(_advl _adv)] ### (14) \, ### (15) @@ # np , vg np , @POST group(4,7,"_clause"); setunsealed(4,"true"); # 07/10/12 AM. # group(3,3,"_advl"); @RULES _xNIL <- _xWILD [one match=(_xSTART _qEOS)] _np \, _vg _xWILD [star match=(_advl _adv)] _np [opt] _xWILD [star match=(_advl _adv)] \, @@ # like @CHECK if (N("qsent50-like",3)) fail(); @POST pnrename(N(3),"_prep"); N("qsent50-like",3) = 1; @RULES _xNIL <- _prep _np like [s] @@ # like @CHECK if (N("qsent50-like",2)) fail(); @POST pnrename(N(2),"_prep"); N("qsent50-like",2) = 1; @RULES _xNIL <- _xWILD [one match=(_advl _vg)] like [s] @@ # np # date @CHECK if (N("sem",2) != "date") fail(); @POST group(2,2,"_advl"); @RULES _xNIL <- _xSTART _np _xWILD [one lookahead match=( \, _np _noun _advl)] @@ # np np # np date @CHECK if (N("sem",3) != "date") fail(); @POST L("tmp3") = N(3); group(3,3,"_advl"); pncopyvars(L("tmp3"),N(3)); clearpos(N(3),1,0); @RULES _xNIL <- _np _xWILD [star match=(_advl _adv)] _np @@ # verb alpha date @CHECK if (N("sem",3) != "date") fail(); if (!N("noun",2)) fail(); @POST L("tmp3") = N(3); group(3,3,"_advl"); pncopyvars(L("tmp3"),N(3)); L("tmp2") = N(2); group(2,2,"_noun"); pncopyvars(L("tmp2"),N(2)); nountonp(2,1); @RULES _xNIL <- _xWILD [one match=(_verb _vg)] _xALPHA _np # 09/24/13 AM. @@ # alpha np # alpha date @CHECK if (N("sem",3) != "date") fail(); if (N("verb",1)) fail(); if (!N("adj",1) && !N("noun",1)) fail(); @POST L("tmp3") = N(3); group(3,3,"_advl"); pncopyvars(L("tmp3"),N(3)); @RULES _xNIL <- _xALPHA _xWILD [star match=(_advl _adv)] _np @@ # np , alpha adv @CHECK if (!N("adj",3)) fail(); @POST L("tmp3") = N(3); group(3,3,"_adj"); pncopyvars(L("tmp3"),N(3)); fixadj(N(3)); @RULES _xNIL <- _np \, _xALPHA _xWILD [plus lookahead match=(_advl _adv)] @@ # prep np @POST group(2,3,"_advl"); N("pp",2) = 1; @RULES _xNIL <- _xWILD [one match=(_pro _np)] _prep _np _xWILD [one fail=( \, _conj)] @@
@POST rfarulesfile(1, 2, 3, 4, 5) single() @RULES # ALLOWING EMPTY RULE REGION IF THERE IS CODE or DECL. _RULESFILE [base] <- _DECL _CODE [opt] _SELECT [opt] _RECURSES [opt] _REGIONS [opt] @@ _RULESFILE [base] <- _DECL [opt] _CODE _SELECT [opt] _RECURSES [opt] _REGIONS [opt] @@ # Could remove _CODE from here, but would need a new action. # _RULESFILE [base] <- _DECL [opt] _CODE [opt] _SELECT [opt] _RECURSES [opt] _REGIONS @@ @POST rfarulesfile(1, 3, 2, 4, 5) single() @RULES # ALLOWING SELECT ZONE TO PRECEDE CODE ZONE. # _RULESFILE [base] <- _DECL [opt] _SELECT _CODE _RECURSES [opt] _REGIONS [opt] @@
@CODE G("root") = findconcept(findroot(),"specialist_lexicon"); if (!G("root")) G("root") = makeconcept(findroot(),"specialist_lexicon"); rmchildren(G("specialist_lexicon")); @@CODE
@CODE G("some global variable") = 1; SomeFunction("moose","running"); "code.txt" << "Hello from the code region!"; @@CODE
@PATH _ROOT _labels _labelEntry @CODE G("currAttr") = 0; @@CODE @POST if (!G("currAttr")) { G("currAttr") = findattrs(X("RID", 3)); } if ( !N("$text", 1) ) { S("empty") = 1; #New L("tempAttr") = G("currAttr"); G("currAttr") = nextattr(G("currAttr")); rmattr(X("RID", 3), attrname(L("tempAttr"))); } else { S("empty") = 0; addstrval(X("RID", 3), attrname(G("currAttr")), N("$text", 1)); G("currAttr") = nextattr(G("currAttr")); } single(); @RULES _columnField <- _xWILD [fails=(\t \n)] ### (1) _xWILD [one matches=(\t \n)] ### (2) @@
# Set the BASE attribute of the first node to "true" or "false" @POST setbase(1,"true"); single();  # Need to put the default reduce in manually, since POST is not empty. @RULES _np <- _noun @@
@CODE #DisplayKB(G("words"), 1); DisplayKB(G("adjMatrixData"), 1); @@CODE
@PATH _ROOT _contactZone _LINE # If name hasn't been selected from _humanName nodes. @CHECK if ( !X("name found",2) && (N("ctcname conf") >= 60) && (N("name found") || N("ctcname conf") == X("hi ctcname conf",2)) ) succeed(); fail(); @POST # Need a way to get all the pieces of a name. # Probably should have been put into semantics already. # For now, designate this name as the chosen one, # and get it in a subsequent round. N("unlabeled") = 1; N("name found") = 1; X("name found") = 1; # Track the line that has the name. X("name found",2) = 1; # Name for contact zone found. X("contactName",2) = N("$text"); # At least get total name here. @RULES _xNIL <- _Caps [rename=(_humanName)] @@
@NODES _LINE @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@NODES _LINE @RULES _SchoolRoot [] <- _xWILD [s one matches=( Conservatory Academy Universidad University College Colleges School Institute Seminary Tech Univ Poly Polytechnic )] @@ # these are in the sample hierarchy, like MIT, UCSB... _SchoolName [] <- _schoolPhrase [s]@@
@NODES _LINE @RULES _SchoolNamePhrase [] <- _xWILD [one s match=(_SchoolNamePhrase _SchoolRoot) ] _xWHITE [s] _xWILD [one s match=(for of) ] _xWHITE [s] _xWILD [one s match=(_CityName _state) layer=(_SchoolLocation)] @@ # Ex: "University of XXX (XXX), -> _SchoolNamePhrase" _SchoolNamePhrase [] <- _xWILD [one s match=(_SchoolNamePhrase _SchoolRoot) ] _xWHITE [star s] _xWILD [one s match=(for of) ] _xWHITE [star s] _xWILD [s opt match=(the)] _xWHITE [s star] _xWILD [one s match=(_Name _major _saintName ) ] #10/09/99 PS _xWHITE [star s] _xWILD [opt s fails=( _xPUNCT _xWHITE _xNUM _degree _major _minor _gpa at _DateRange _SingleDate)] # 10/09/99 PS @@ # Ex: "University of XXX (XXX), -> _SchoolNamePhrase" _SchoolNamePhrase [] <- _xWILD [one s match=(_SchoolNamePhrase _SchoolRoot) ] _xWHITE [star s] _xWILD [one s match=(for of) ] _xWHITE [star s] _xWILD [s opt match=(the)] _xWHITE [s star] _xWILD [one s match=( _state _CityName ) layer=(_SchoolLocation)] #10/09/99 PS _xWHITE [star s] _xWILD [opt s fails=( _xPUNCT _xWHITE _xNUM _degree _major _minor _gpa at _DateRange _SingleDate)] # 10/09/99 PS @@ _SchoolNamePhrase [] <- _xWILD [one s match=(_SchoolNamePhrase _SchoolRoot) ] _xWHITE [star s] _xWILD [one s match=(for of) ] _xWHITE [star s] _xWILD [s opt match=(the)] _xWHITE [s star] _xALPHA [s] _xWHITE [star s] _xWILD [opt s fails=( _xPUNCT _xWHITE _xNUM _degree _major _minor _gpa at and # 10/25/99 AM. _DateRange _SingleDate)] # 10/09/99 PS @@
# Doing this rigamarole in case region is empty. @NODES _CODE _CHECKS _PRES _POSTS _NODES _PATH _MULTI _RULES _DECL @POST excise(1,1) @RULES _xNIL <- _xWILD [one match=(_startMark _endMark)] @@
@DECL figureImageFilename(L("filename")) { L("filename") = strsubst(L("filename"),"/","-"); L("tit") = strsubst(G("title")," ","-"); L("tit") = strsubst(L("tit"),"'","-"); L("auths") = strsubst(G("authors")," ","-"); L("newfile") = L("auths") + "-" + L("tit") + "-" + L("filename"); if (!strcontainsnocase(".png",L("filename")) && !strcontainsnocase(".jpg",L("filename"))) { L("newfile") = L("newfile") + ".jpg"; } "images.txt" << L("newfile") << "\n"; return L("newfile"); } transQuotes(L("text"),L("tag"),L("quotes")) { L("start") = "\\" + L("tag") + "{"; "debug.txt" << "transQuotes text: " << L("text") << "\n"; "debug.txt" << "transQuotes tag: " << L("tag") << "\n"; "debug.txt" << "transQuotes quotes: " << L("quotes") << "\n"; L("new text") = strsubst(L("text"),L("start"),L("quotes")); L("new text") = strsubst(L("new text"),"}",L("quotes")); return L("new text"); } addFigure(L("name")) { "kb.txt" << "addFigure: " << L("name") << "\n"; G("fig count") = G("fig count") + 1; L("con") = findconcept(G("figures"),L("name")); if (!L("con")) makeconcept(G("figures"),L("name")); } addEquationName(L("name")) { "kb.txt" << "addEquation: " << L("name") << "\n"; G("ref count") = G("ref count") + 1; L("con") = findconcept(G("equations"),L("name")); if (!L("con")) { L("con") = makeconcept(G("equations"),L("name")); } G("equation") = G("equation") + 1; addnumval(L("con"),"number",G("equation")); addstrval(L("con"),"name",L("name")); } addReference(L("name"),L("ref type"),L("type")) { "kb.txt" << "addReference: " << L("name") << "\n"; G("ref count") = G("ref count") + 1; L("con") = findconcept(G("references"),L("name")); if (!L("con")) { L("con") = makeconcept(G("references"),L("name")); } addstrval(L("con"),"ref type",L("ref type")); addstrval(L("con"),"type",L("type")); } addCite(L("name")) { "kb.txt" << "addCite: " << L("name") << "\n"; G("ref count") = G("ref count") + 1; L("con") = findconcept(G("cites"),L("name")); if (!L("con")) { L("con") = makeconcept(G("cites"),L("name")); } } addBib(L("name"),L("body")) { "bib.txt" << "addBib: " << L("name") << "\n"; "bib.txt" << " body in: " << L("body") << "\n"; G("ref count") = G("ref count") + 1; L("con") = findconcept(G("bibliography"),L("name")); if (!L("con")) { L("con") = makeconcept(G("bibliography"),L("name")); } else { L("str") = strval(L("con"),"body"); L("body") = L("str") + " " + L("body"); } "bib.txt" << " body new: " << L("body") << "\n"; replaceval(L("con"),"body",L("body")); } getRefereceBody(L("name")) { "cite.txt" << "getRefereceBody: " << L("name") << "\n"; L("con") = findconcept(G("bibliography"),L("name")); L("body") = strval(L("con"),"body"); "cite.txt" << "getRefereceBody: " << L("body") << "\n"; return L("body"); } addEquationToLabel(L("label"),L("equation")) { "equation.txt" << "addEquationToLabel: " << L("label") << ", " << L("equation") << "\n"; L("con") = findconcept(G("equations"),L("label")); "equation.txt" << "Concept name found: " << conceptname(L("con")) << "\n"; addstrval(L("con"),"equations",L("equation")); } findEquation(L("label")) { "equation.txt" << "findEquation: " << L("label") << "\n"; L("con") = findconcept(G("equations"),L("label")); "equation.txt" << "Concept name found: " << conceptname(L("con")) << "\n"; return L("con"); } getEquationNumber(L("label")) { "equation.txt" << "getEquationNumber: " << L("label") << "\n"; L("con") = findconcept(G("equations"),L("label")); "equation.txt" << "Concept name found: " << conceptname(L("con")) << "\n"; L("number") = numval(L("con"),"number"); "equation.txt" << "getEquationNumber: " << L("number") << "\n"; return L("number"); } cleanEquation(L("equ")) { "equation.txt" << "Before: " << L("equ") << "\n"; L("equ") = strsubst(L("equ"),"& =","="); L("equ") = strsubst(L("equ"),"&=","="); L("equ") = strsubst(L("equ"),"\\\\"," "); L("equ") = strtrim(L("equ")); "equation.txt" << "After: " << L("equ") << "\n"; return L("equ"); } @@DECL
@PATH _ROOT _textZone _LINE @POST X("list") = 1; "list.txt" << N("$text",3) << "\n"; @RULES _xNIL <- _xSTART ### (1) \: [opt] ### (2) \# ### (3) @@
@NODES _ROOT @POST "kb.txt" << conceptpath(G("part")) << "\n"; "kb.txt" << G("last indent") << " " << N("indent") << " " << N("title") << "\n"; while (G("last indent") && G("last indent") >= N("indent")) { "kb.txt" << " " << G("last indent") << " " << N("indent") << " <=======\n"; G("part") = up(G("part")); G("last indent") = G("last indent") - 2; } G("part") = makeconcept(G("part"),N("title")); G("last indent") = N("indent"); @RULES _xNIL <- _LINE ### (1) @@
@NODES _ROOT @RULES _Comment <- _CommentStart [one] ### (1) _xWILD [star fail=("_CommentEnd" "_CommentEnd" "_DoubleHyphen")] ### (2) _CommentEnd [one] ### (3) @@ _ExternalID <- _xWILD [one matches=("PUBLIC")] ### (1) _whiteSpace [opt] ### (2) _PubidLiteral [one] ### (3) _whiteSpace [opt] ### (4) _PubidLiteral [one] ### (5) @@ _ExternalID <- _xWILD [one matches=("PUBLIC")] ### (1) _whiteSpace [opt] ### (2) _PubidLiteral [one] ### (3) _whiteSpace [opt] ### (4) _SystemLiteral [one] ### (5) @@ _ExternalID <- _xWILD [one matches=("SYSTEM")] ### (1) _whiteSpace [opt] ### (2) _PubidLiteral [one] ### (3) @@ _ExternalID <- _xWILD [one matches=("SYSTEM")] ### (1) _whiteSpace [opt] ### (2) _SystemLiteral [one] ### (3) @@ @@RULES @POST S("ElementName") = N("ElementName",1) ; single() ; @@POST @RULES _AttlistDecl [unsealed] <- _AttlistDeclStart [one] ### (1) _whiteSpace [opt] ### (2) _xWILD [plus fail=("_EndTag")] ### (3) _whiteSpace [opt] ### (4) _EndTag [one] ### (5) @@ _PCDataStart <- \( [one] ### (1) _whiteSpace [opt] ### (2) \# [one] ### (3) _xALPHA [s one matches=("#PCDATA")] ### (4) @@ _EntityDecl <- _EntityDeclStart [one] ### (1) _whiteSpace [opt] ### (2) _xWILD [plus fail=("_EndTag" "_CommentEnd" "_EndEmptyTag" "EndDocType")] ### (3) _whiteSpace [opt] ### (4) _EndTag [one] ### (5) @@ _EntityDecl <- _EntityDeclStart [one] ### (1) _whiteSpace [opt] ### (2) _xWILD [min=1 max=0 fail=("_EndTag" "_CommentEnd" "_EndEmptyTag" "EndDocType")] ### (3) _whiteSpace [opt] ### (4) _CommentEnd [one] ### (5) @@ _EntityDecl <- _EntityDeclStart [one] ### (1) _whiteSpace [opt] ### (2) _xWILD [min=1 max=0 fail=("_EndTag" "_CommentEnd" "_EndEmptyTag" "EndDocType")] ### (3) _whiteSpace [opt] ### (4) _EndEmptyTag [one] ### (5) @@ _EntityDecl <- _EntityDeclStart [one] ### (1) _whiteSpace [opt] ### (2) _xWILD [min=1 max=0 fail=("_EndTag" "_CommentEnd" "_EndEmptyTag" "EndDocType")] ### (3) _whiteSpace [opt] ### (4) _EndDocType [one] ### (5) @@ @@RULES
@PATH _ROOT _experienceZone _experienceInstance @POST # Before zapping anchor, copy its line number to instance. X("anchor lineno") = N("lineno",1); splice(1,1); # Zap the _expStart node @RULES _xNIL <- _ANCHOR @@
@NODES _td @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
# Fetch value as a string from a numeric or string-valued KB value object. L("return_str") = getsval(L("val"));
@CODE DisplayKB(G("P_eui"), 1); SaveKB("P_eui.kbb",G("P_eui"),1); @@CODE
@PATH _ROOT _bibItem @POST addBib(X("ref",0)," - "); @RULES _xNIL <- _dash [s] ### (1) @@ @POST addBib(X("ref",0)," ''"); @RULES _xNIL <- _bold ### (1) @@ @POST addBib(X("ref",0)," '''"); @RULES _xNIL <- _emph ### (1) @@ @POST addBib(X("ref",0)," '''"); @RULES _xNIL <- _italics ### (1) @@ @POST addBib(X("ref",0),N("$text")); @RULES _xNIL <- _text ### (1) @@
@NODES _ROOT @POST S("rowspan") = N("rowspan",1); single(); @RULES _td <- _tdOpen ### (1) _xWILD [fail=(_tdClose)] ### (2) _tdClose ### (3) @@
@NODES _ROOT @RULES _td <- _tdOpen ### (1) _xWILD [fail=(_tdClose _tdOpen)] _tdClose @@
@CODE G("terms") = findconcept(findroot(),"terms"); if (!G("terms")) G("terms") = makeconcept(findroot(),"terms"); rmchildren(G("terms")); @@CODE
@PATH _ROOT _DECL _NLPPP #@POST # movesem(1) # single() #@RULES #_ACTION [base] <- # _STMTS [s] # @@ #@POST # setbase(1,"true") # Not sure if this is needed for anything. #@RULES #_xNIL <- _STMTS [s] @@ # @POST rfbdecl(1,2) single() @RULES _FUNCDEF <- _FNCALL _STMTS # This needs to be a BLOCK. @@
@NODES _ROOT @RULES _itemOpen <- \< ### (1) item ### (2) \> ### (3) @@ _itemClose <- \< ### (1) \/ ### (2) item ### (3) \> ### (4) @@ _categoryidOpen <- \< ### (1) categoryid ### (2) \> ### (3) @@ _categoryidClose <- \< ### (1) \/ ### (2) categoryid ### (3) \> ### (4) @@ _nameOpen <- \< ### (1) name ### (2) \> ### (3) @@ _nameClose <- \< ### (1) \/ ### (2) name ### (3) \> ### (4) @@ _tooltipOpen <- \< ### (1) tooltip ### (2) \> ### (3) @@ _tooltipClose <- \< ### (1) \/ ### (2) tooltip ### (3) \> ### (4) @@
@CODE if (G("$isdirrun")) { L("write") = "app"; } else { L("write") = "w"; } L("debugpath") = G("$kbpath") + "debug.txt"; G("debug") = openfile(L("debugpath"),L("write")); L("vocab") = G("$kbpath") + "vocab.dictt"; # L("vocab") = "vocab.dict"; G("vocab") = openfile(L("vocab"),"app"); @@CODE
@NODES _LINE @RULES _CompleteSchoolName <- _CompleteSchoolName [s] _xWHITE [s] _xWILD [s one matches = ( and And \& )] _xWHITE [s] _xWILD [s one matches = ( _CompleteSchoolName _SchoolRoot _SchoolNamePhrase)] @@ _CompleteSchoolName <- _CompleteSchoolName [s] _xWHITE [s] _xWILD [s one matches = ( _CompleteSchoolName _SchoolRoot _SchoolNamePhrase)] @@ _CompleteSchoolName <- _SchoolNamePhrase [s] @@
@NODES _td @POST excise(1,1); @RULES _xNIL <- _xWILD [one match=(_tag _tdOpen _tdClose)] ### (1) @@
@NODES _ROOT @CHECK if ( N("Numeral Value",1) <1000000) fail(); if ( N("Numeral Value",3) > 999999 ) fail(); if ( N("Numeral Value",5) > 999 ) fail(); if ( N("Numeral Value",9) > 99 ) fail(); @@CHECK @POST G("num1") = N("Numeral Value",1) ; G("num2") = N("Numeral Value",3) ; G("num3") = N("Numeral Value",5) ; G("num4") = N("Numeral Value",9) ; S("Numeral Value") = G("num1") + G("num2") + G("num3") + G("num4") ; single(); @@POST @RULES _cardinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (4) _cardinalNumeral [s one] ### (5) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6) _xWILD [s opt match=("and" "&")] ### (7) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (8) _cardinalNumeral [s one] ### (9) @@ _ordinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (4) _cardinalNumeral [s one] ### (5) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6) _xWILD [s opt match=("and" "&")] ### (7) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (8) _ordinalNumeral [s one] ### (9) @@ @@RULES @CHECK if ( N("Numeral Value",1) <1000) fail(); if ( N("Numeral Value",3) > 999 ) fail(); if ( N("Numeral Value",7) > 99 ) fail(); @@CHECK @POST G("num1") = N("Numeral Value",1) ; G("num2") = N("Numeral Value",3) ; G("num3") = N("Numeral Value",7) ; S("Numeral Value") = G("num1") + G("num2") + G("num3") ; single(); @@POST @RULES _cardinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _xWILD [s opt match=("and" "&")] ### (5) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (6) _cardinalNumeral [s one] ### (7) @@ _ordinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _xWILD [s opt match=("and" "&")] ### (5) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6) _ordinalNumeral [s min=1 max=1] ### (7) @@ @@RULES @CHECK if ( N("Numeral Value",1) <1000000) fail(); if ( N("Numeral Value",3) > 999999 ) fail(); if ( N("Numeral Value",7) > 99 ) fail(); @@CHECK @POST G("num1") = N("Numeral Value",1) ; G("num2") = N("Numeral Value",3) ; G("num3") = N("Numeral Value",7) ; S("Numeral Value") = G("num1") + G("num2") + G("num3") ; single(); @@POST @RULES _cardinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _xWILD [s opt match=("and" "&")] ### (5) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6) _cardinalNumeral [s one] ### (7) @@ _ordinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _xWILD [s opt match=("and" "&")] ### (5) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6) _ordinalNumeral [s one] ### (7) @@ @@RULES @CHECK if ( N("Numeral Value",1) <1000) fail(); if ( N("Numeral Value",3) > 999 ) fail(); if ( N("Numeral Value",7) > 99 ) fail(); @@CHECK @POST G("num1") = N("Numeral Value",1) ; G("num2") = N("Numeral Value",3) ; G("num3") = N("Numeral Value",7) ; S("Numeral Value") = G("num1") + G("num2") + G("num3") ; single(); @@POST @RULES _cardinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _xWILD [s opt match=("and" "&")] ### (5) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6) _cardinalNumeral [s one] ### (7) @@ _ordinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _xWILD [s opt match=("and" "&")] ### (5) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6) _ordinalNumeral [s one] ### (7) @@ @@RULES @CHECK if ( N("Numeral Value",1) <1000000 ) fail(); if ( N("Numeral Value",3) > 999999 ) fail(); @@CHECK @POST G("num1") = N("Numeral Value",1) ; G("num2") = N("Numeral Value",3) ; S("Numeral Value") = G("num1") + G("num2") ; single(); @@POST @RULES _cardinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) @@ _ordinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2) _ordinalNumeral [s one] ### (3) @@ @@RULES @CHECK if ( N("Numeral Value",1) <1000 ) fail(); if ( N("Numeral Value",3) > 999 ) fail(); @@CHECK @POST G("num1") = N("Numeral Value",1) ; G("num2") = N("Numeral Value",3) ; S("Numeral Value") = G("num1") + G("num2") ; single(); @@POST @RULES _cardinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2) _cardinalNumeral [s one] ### (3) @@ _ordinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2) _ordinalNumeral [s one] ### (3) @@ @@RULES @CHECK if ( N("Numeral Value",1) <100 ) fail(); if ( N("Numeral Value",3) > 99 ) fail(); @@CHECK @POST G("num1") = N("Numeral Value",1) ; G("num2") = N("Numeral Value",5) ; S("Numeral Value") = G("num1") + G("num2") ; single(); @@POST @RULES _cardinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2) _xWILD [s opt match=("and" "&")] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _cardinalNumeral [s one] ### (5) @@ _ordinalNumeral <- _cardinalNumeral [s one] ### (1) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2) _xWILD [s opt match=("and" "&")] ### (3) _xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4) _ordinalNumeral [s one] ### (5) @@ @@RULES
@CODE L("hello") = 0; @@CODE @NODES _sent # Count clauses in a sentence. @POST N("clause num") = ++X("clauses"); @RULES _xNIL <- _clause @@ # ^ if @POST X("conditional") = 1; # 05/08/07 AM. @RULES _xNIL <- _xSTART if [s] @@
@NODES _ROOT @POST S("level") = N("$text",4); "headers.txt" << N("$text",4) << " close\n"; single(); @RULES _headerClose <- \< ### (1) \/ h ### (2) _xNUM ### (3) \> ### (4) @@ @POST S("level") = N("$text",3); "headers.txt" << N("$text",3) << " open\n"; single(); @RULES _header <- \< ### (1) h ### (2) _xNUM ### (3) \> ### (4) @@
@CODE prlit("zdump.txt", "\nCap Phrases (BEFORE CONJUNCTION MERGE)\n"); prlit("zdump.txt", "----------------------------------------\n"); @@CODE @PATH _ROOT _LINE @POST ndump("zdump.txt",1); prlit("zdump.txt", "-------\n"); @RULES _xNIL <- _Caps @@
@CODE G("hello") = 0; @@CODE #@PATH _ROOT _TEXTZONE _sent _clause @NODES _clause # vg to vg @POST L("tmp1") = N(1); L("tmp5") = N(5); group(1,5,"_vg"); X("voice") = N("voice",1) = "active"; # Syntax from 1st. N("verb node",1) = pnvar(L("tmp1"),"verb node"); N("first verb",1) = pnvar(L("tmp1"),"first verb"); # Semantics from 2nd. N("sem",1) = pnvar(L("tmp5"),"sem"); N("stem",1) = pnvar(L("tmp5"),"stem"); X("vg node") = N(1); clearpos(N(1),1,0); @RULES _xNIL <- _vg _xWILD [star match=(_advl _adv)] to [s] _xWILD [star match=(_advl _adv)] _vg @@ @POST X("to-vg") = N("to-vg",3) = 1; listadd(3,1,"true"); @RULES _xNIL <- to [s] _xWILD [star match=(_advl _adv)] _vg @@ # Note: Updated, but still cruddy logic. # # Note: Clause should record if by-np, by-actor seen. # alpha advl @CHECK if (!N("verb",3)) fail(); if (N("noun",3)) fail(); @POST if (pnname(N(4)) == "_np") L("np") = 1; else if (N(2)) { if (pnname(N(2)) == "_np") L("np") = 1; } if (L("np")) { alphatovg(3,"active","VBP"); X("voice") = "active"; } else if (!vconjq(N(3),"-en")) { alphatovg(3,"active","VBP"); X("voice") = "active"; } else { alphatovg(3,"passive","VBN"); X("voice") = "passive"; } @RULES _xNIL <- _xSTART _xWILD [star match=(_advl _adv _np)] _xALPHA _xWILD [one lookahead match=(_advl _adv _np)] @@ # Characterize some clause patterns.... @POST if (N("verb",3)) { if (vconjq(N(4),"-ing")) X("pattern") = "ving"; } @RULES _xNIL <- _xSTART _xWILD [star match=(_advl _adv)] _xALPHA _xWILD [star match=(_advl _adv)] _xEND @@
@NODES _LINE @POST singler(2,2); @RULES _code <- _xSTART ### (1) _word @@
@CODE L("hello") = 0; @@CODE
@CODE G("pos") = findconcept(findroot(),"pos"); if (!G("pos")) G("pos") = makeconcept(findroot(),"pos"); rmchildren(G("pos")); @@CODE
@NODES _ROOT @RULES _np <- _xWILD [s plus match=(_det _adj)] ### (1) _xWILD [s plus match=(_noun)] ### (2) @@
@NODES _ROOT @PRE <1,1> var("header"); @POST splice(1,1); @RULES _xNIL <- _LINE ### (1) @@
@PATH _ROOT _addendum @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@PATH _ROOT _paragraph _sentence @POST pncopyvars(); single(); @RULES _company <- _det [s] ### (1) _company [s] ### (2) @@
# Close the output file stream @CODE G("file") = openfile("c:\\tmp.txt"); closefile(G("file")); @@CODE
@CODE if (!G("find html")) exitpass(); # If no title found, flag it. if (!G("title")) { if (G("error")) { L("fname") = G("$apppath") + "\\data\\errhtml.txt"; L("errhtml") = openfile(L("fname"),"app"); L("errhtml") << G("$inputhead") << ": No title found." << "\n"; closefile(L("errhtml")); } } else if (G("verbose")) { L("fname") = G("$apppath") + "\\data\\htmltitle.txt"; L("htmltitle") = openfile(L("fname"),"app"); L("htmltitle") << G("$inputhead") << ": " << G("title") << "\n"; closefile(L("htmltitle")); } @@CODE @NODES _ROOT _headerZone @CHECK if (!N("tag")) # Not a tag. fail(); @POST excise(1,1); @RULES _xNIL <- _xANY # Need an _xNONLIT and _xLIT @@
@NODES _ROOT @POST G("dict") << N("word") << " " << N("attr") << "=" << N("value") << "\n"; @RULES _xNIL <- _attrBlock ### (1) @@
@CODE fileout("ctc.txt"); @@CODE # For otherZone at the beginning of a resume, if it has # noteworthy addressParts, rename it to contactZone. # NOTE: A temporary heuristic. If experience zone is next, it may # well have cityState constructs. Need to decide what the next zone # really is, once we start dealing with things beyond contact zones. # @NODES _ROOT # @PATH _ROOT # 10/19/99 AM. @CHECK if (N("addressParts",2) < 2) fail(); # 12/25/99 AM. # Nge(2, "addressParts", 2) # @POST noop(); @RULES _xNIL <- _contactZone [s] _otherZone [s ren=(_contactZone)] @@
@NODES _LINE @RULES # Ex: employment\_history _ExperienceHeaderPhrase [layer=(_header )] <- employment [s] _xWHITE [star s] history [s] @@ # Ex: employment\_experience _ExperienceHeaderPhrase [layer=(_header )] <- employment [s] _xWHITE [star s] experience [s] @@ # Ex: work\_experience _ExperienceHeaderPhrase [layer=(_header )] <- work [s] _xWHITE [star s] experience [s] @@ @PRE <1,1> cap(); @RULES # Ex: Professional\_experience _ExperienceHeaderPhrase [layer=(_header )] <- Professional [s] _xWHITE [star s] experience [s] @@ @PRE <1,1> cap(); <3,3> cap(); @RULES # Ex: Career\_History _ExperienceHeaderPhrase [layer=(_header )] <- Career [s] _xWHITE [star s] History [s] @@ # Ex: WORK\_HISTORY _ExperienceHeaderPhrase [layer=(_header )] <- WORK [s] _xWHITE [star s] HISTORY [s] @@ # Ex: Project\_History _ExperienceHeaderPhrase [layer=(_header )] <- Project [s] _xWHITE [star s] History [s] @@
@NODES _RECORD #===================== First Record Item ====================== @POST X("field con") = down(G("fields con")); if (!N("value")) N("value") = " "; addstrval(X("record con"),conceptname(X("field con")),N("value")); @RULES _xNIL <- _xSTART [s] ### (1) _item ### (2) @@ #======================= Rest of Items ======================== @POST X("field con") = next(X("field con")); if (!N("value")) N("value") = " "; addstrval(X("record con"),conceptname(X("field con")),N("value")); @RULES _xNIL <- _item ### (1) @@
@NODES _LINE @PRE <1,1> cap(); <3,3> cap(); @RULES # Ex: Back\_To _WebLinks <- Back [s] _xWHITE [star s] To [s] @@ # Ex: My\_Page _WebLinks <- My [s] _xWHITE [star s] Page [s] @@ # Ex: Cool\_Links _WebLinks <- Cool [s] _xWHITE [star s] Links [s] @@ @PRE <2,2> cap(); @RULES # Ex: [Image] _WebLinks <- \[ [s] Image [trig s] \] [s] @@
@NODES _LINE @RULES # Ex: la _PostalRoad <- _xWILD [min=1 max=1 s match=("la" "alley" "ally" "aly" "anex" "annex" "annx" "anx" "arc" "arcade" "av" "ave" "aven" "avenu" "avenue" "avn" "avnue" "bayoo" "bayou" "bch" "beach" "bend" "bg" "bgs" "blf" "blfs" "bluf" "bluff" "bluffs" "blvd" "bnd" "bot" "bottm" "bottom" "boul" "boulevard" "boulv" "br" "branch" "brdge" "brg" "bridge" "brk" "brks" "brnch" "brook" "brooks" "btm" "burg" "burgs" "byp" "bypa" "bypas" "bypass" "byps" "byu" "camp" "canyn" "canyon" "cape" "causeway" "causway" "cen" "cent" "center" "centers" "centr" "centre" "cir" "circ" "circl" "circle" "circles" "cirs" "ck" "clb" "clf" "clfs" "cliff" "cliffs" "club" "cmn" "cmp" "cnter" "cntr" "cnyn" "common" "cor" "corner" "corners" "cors" "course" "court" "courts" "cove" "coves" "cp" "cpe" "cr" "crcl" "crcle" "crecent" "creek" "cres" "crescent" "cresent" "crest" "crk" "crossing" "crossroad" "crscnt" "crse" "crsent" "crsnt" "crssing" "crssng" "crst" "crt" "cswy" "ct" "ctr" "ctrs" "cts" "curv" "curve" "cv" "cvs" "cyn" "dale" "dam" "div" "divide" "dl" "dm" "dr" "driv" "drive" "drives" "drs" "drv" "dv" "dvd" "est" "estate" "estates" "ests" "exp" "expr" "express" "expressway" "expw" "expy" "ext" "extension" "extensions" "extn" "extnsn" "exts" "fall" "falls" "ferry" "field" "fields" "flat" "flats" "fld" "flds" "fls" "flt" "flts" "ford" "fords" "forest" "forests" "forg" "forge" "forges" "fork" "forks" "fort" "frd" "frds" "freeway" "freewy" "frg" "frgs" "frk" "frks" "frry" "frst" "frt" "frway" "frwy" "fry" "ft" "fwy" "garden" "gardens" "gardn" "gateway" "gatewy" "gatway" "gdn" "gdns" "glen" "glens" "gln" "glns" "grden" "grdn" "grdns" "green" "greens" "grn" "grns" "grov" "grove" "groves" "grv" "grvs" "gtway" "gtwy" "harb" "harbor" "harbors" "harbr" "haven" "havn" "hbr" "hbrs" "height" "heights" "hgts" "highway" "highwy" "hill" "hills" "hiway" "hiwy" "hl" "hllw" "hls" "hollow" "hollows" "holw" "holws" "hrbor" "ht" "hts" "hvn" "hway" "hwy" "inlet" "inlt" "is" "island" "islands" "isle" "isles" "islnd" "islnds" "iss" "jct" "jction" "jctn" "jctns" "jcts" "junction" "junctions" "junctn" "juncton" "key" "keys" "knl" "knls" "knol" "knoll" "knolls" "ky" "kys" "allee" "lake" "lakes" "land" "landing" "lane" "lanes" "lck" "lcks" "ldg" "ldge" "lf" "lgt" "lgts" "light" "lights" "lk" "lks" "ln" "lndg" "lndng" "loaf" "lock" "locks" "lodg" "lodge" "loop" "loops" "mall" "manor" "manors" "mdw" "mdws" "meadow" "meadows" "medows" "mews" "mill" "mills" "mission" "missn" "ml" "mls" "mnr" "mnrs" "mnt" "mntain" "mntn" "mntns" "motorway" "mount" "mountain" "mountains" "mountin" "msn" "mssn" "mt" "mtin" "mtn" "mtns" "mtwy" "nck" "neck" "opas" "orch" "orchard" "orchrd" "oval" "overpass" "ovl" "park" "parks" "parkway" "parkways" "parkwy" "pass" "passage" "path" "paths" "pike" "pikes" "pine" "pines" "pk" "pkway" "pkwy" "pkwys" "pky" "pl" "place" "plain" "plaines" "plains" "plaza" "pln" "plns" "plz" "plza" "pne" "pnes" "point" "points" "port" "ports" "pr" "prairie" "prarie" "prk" "prr" "prt" "prts" "psge" "pt" "pts" "rad" "radial" "radiel" "radl" "ramp" "ranch" "ranches" "rapid" "rapids" "rd" "rdg" "rdge" "rdgs" "rds" "rest" "ridge" "ridges" "riv" "river" "rivr" "rnch" "rnchs" "road" "roads" "route" "row" "rpd" "rpds" "rst" "rte" "rue" "run" "rvr" "shl" "shls" "shoal" "shoals" "shoar" "shoars" "shore" "shores" "shr" "shrs" "skwy" "skyway" "smt" "spg" "spgs" "spng" "spngs" "spring" "springs" "sprng" "sprngs" "spur" "spurs" "sq" "sqr" "sqre" "sqrs" "sqs" "squ" "square" "squares" "st" "sta" "station" "statn" "stn" "str" "stra" "strav" "strave" "straven" "stravenue" "stravn" "stream" "street" "streets" "streme" "strm" "strt" "strvn" "strvnue" "sts" "sumit" "sumitt" "summit" "ter" "terr" "terrace" "throughway" "tpk" "tpke" "tr" "trace" "traces" "track" "tracks" "trafficway" "trail" "trails" "trak" "trce" "trfy" "trk" "trks" "trl" "trls" "trnpk" "trpk" "trwy" "tunel" "tunl" "tunls" "tunnel" "tunnels" "tunnl" "turnpike" "turnpk" "un" "underpass" "union" "unions" "uns" "upas" "valley" "valleys" "vally" "vdct" "via" "viadct" "viaduct" "view" "views" "vill" "villag" "village" "villages" "ville" "villg" "villiage" "vis" "vist" "vista" "vl" "vlg" "vlgs" "vlly" "vly" "vlys" "vst" "vsta" "vw" "vws" "walk" "walks" "wall" "way" "ways" "well" "wells" "wl" "wls" "wy" "xing" "xrd")] @@
# Create the concept apple, then create two attributes of apple, then delete both of them. Finally, add both of the attributes back and then delete only one if(findconcept(findroot(), "apples")) rmconcept(findconcept(findroot(), "apples")); G("apples") = makeconcept(findroot(), "apples"); addstrval(G("apples"), "color", "red"); addstrval(G("apples"), "taste", "good"); rmattrs(G("apples")); addstrval(G("apples"), "color", "red"); addstrval(G("apples"), "taste", "good"); rmattr(G("apples"),"color");
@PATH _ROOT _paragraph _sentence @POST excise(1,1); @RULES _xNIL <- _xWHITE [s] ### 1 @@
@PATH _ROOT _LINE _item @POST if (X("num",2)) { group(2,2,"_title"); } @RULES _xNIL <- _indent ### (1) _xWILD [fail=(_xEND)] ### (2) _xEND ### (3) @@
@MULTI _ROOT @POST singler(2,2); @RULES _properNoun <- _xWILD [one fails=(_xSTART \")] _xCAP [plus] ### (1) _xWILD [opt matches=(and & of \-)] _xWILD [] @@
@NODES _LINE @POST singler(1,1); @RULES _phrase <- _xWILD [fail=(_code)] ### (1) _code ### (2) @@
@NODES _paragraph @POST excise(1,1); noop(); @RULES _xNIL <- _xWILD [match=(_xWHITE _xCTRL)] ### (1) @@
# This will match words such as JUNK, junks, junky, JunkYard @PRE <1,1> regexpi("junk*"); @POST group(1,1,"_junkword"); @RULES _xNIL <- _xALPHA @@
@PATH _ROOT _header _identifier @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@PATH _ROOT _addendum @POST L("radLexTerms") = GetRadLexTerms(N(3)); "log.txt" << "\n++++++++++++ printing " << arraylength(L("radLexTerms")) << " items in addendum +++++++++++++++++\n"; "radLexTerms.txt" << N("$text", 1) << "\n"; if(L("radLexTerms")) { L("count") = 0; while (L("count") < arraylength(L("radLexTerms"))) { "radLexTerms.txt" << "\t" << L("radLexTerms")[L("count")] << "\n"; L("count") = L("count") + 1; } } @RULES _xNIL <- _title ### (1) _header [opt] ### (2) _xWILD [one match=(_xALPHA _xNUM)] ### (3) @@
@PATH _ROOT _doctypedecl @RULES _choiceElement [unsealed] <- _whiteSpace [opt] ### (1) \| [one] ### (2) _whiteSpace [opt] ### (3) _cp [one] ### (4) _xWILD [opt matches=("*" "+" "?")] ### (5) @@ _seqElement [unsealed] <- _whiteSpace [opt] ### (1) \, [one] ### (2) _whiteSpace [opt] ### (3) _cp [one] ### (4) _xWILD [opt matches=("*" "+" "?")] ### (5) @@
@NODES _LINE @POST L("file") = "icd.kbb"; L("hier") = "icdhier.kbb"; if (X("num")) { if (X("num") == 1 && N("num") == 0) { L("file") << "ICD11"; L("hier") << "ICD11"; } if (N("num") == 0 && N("value")) { X("code") = N("value"); } else if (N("num") == 1 && N("value")) { X("code") = N("value"); } else if (N("num") == 2) { L("code") = X("code"); # if (strcontains(".",L("code")) || strcontains("-",L("code"))) { # L("code") = "\"" + L("code") + "\""; # } if (!L("code")) { L("kind") = X("ClassKind"); L("code") = strtotitle(L("kind")) + PadStr(str(G("chapter")++),"0",3); } else if (X("code")) { "codetitles.txt" << SpacesStr(N("indent")+1) << X("code") << " " << N("title") << "\n"; } L("file") << "\n" << SpacesStr(N("indent")) << "\"" << L("code") << "\""; L("hier") << "\n" << SpacesStr(N("indent")) << "\"" << L("code") << "\""; if (strlength(N("title")) > 1) { L("file") << ": title=\"" << N("title") << "\""; L("hier") << ": title=\"" << N("title") << "\""; } } if (N("num") > 2 && N("value")) { L("file") << " " << N("header") << "=[" << N("value") << "]"; } } @RULES _xNIL <- _item @@
@NODES _LINE @PRE <1,1> cap(); @RULES # Ex: SE _Direction <- _xWILD [min=1 max=1 s match=("SE" "South" "East" "West" "NE" "NW" "North" "SW" "N" "S" "E" "W")] @@
@PATH _ROOT _doctypedecl _AttlistDecl @RULES _AttType [unsealed] <- _xWILD [s one matches=("NOTATION")] ### (1) _whiteSpace [opt] ### (2) \( [one] ### (3) _whiteSpace [opt] ### (4) _xWILD [s min=1 max=1 matches=("_xALPHA" "_" ":")] ### (5) _xWILD [s min=0 max=0 matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (6) _xWHITE [opt] ### (7) _EnumNameElement [min=0 max=0] ### (8) \) [one] ### (9) @@ _AttType [unsealed] <- \( [one] ### (1) _whiteSpace [opt] ### (2) _xWILD [s plus matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3) _whiteSpace [opt] ### (4) _EnumElement [star] ### (5) \) [one] ### (6) @@ _AttType [unsealed] <- \( [one] ### (1) _whiteSpace [opt] ### (2) _xWILD [s plus matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3) _whiteSpace [opt] ### (4) _EnumNameElement [star] ### (5) \) [one] ### (6) @@
@NODES _LINE @PRE <1,1> cap() <3,3> cap() @RULES # Ex: MS\_Access _MSSoftware <- MS [s] _xWHITE [star s] Access [s] @@ # Ex: MS\_BackOffice _MSSoftware <- MS [s] _xWHITE [star s] BackOffice [s] @@ # Ex: MS\_Excel _MSSoftware <- MS [s] _xWHITE [star s] Excel [s] @@ # Ex: MS\_FrontPage _MSSoftware <- MS [s] _xWHITE [star s] FrontPage [s] @@ @PRE <1,1> cap() <3,3> cap() <5,5> cap() @RULES # Ex: MS\_Internet\_Explorer _MSSoftware <- MS [s] _xWHITE [star s] Internet [s] _xWHITE [star s] Explorer [s] @@ @PRE <1,1> cap() <3,3> cap() @RULES # Ex: MS\_ODBC _MSSoftware <- MS [s] _xWHITE [star s] ODBC [s] @@ # Ex: MS\_Outlook _MSSoftware <- MS [s] _xWHITE [star s] Outlook [s] @@ # Ex: MS\_PowerPoint _MSSoftware <- MS [s] _xWHITE [star s] PowerPoint [s] @@ # Ex: MS\_Project _MSSoftware <- MS [s] _xWHITE [star s] Project [s] @@ @PRE <1,1> cap() <3,3> cap() <5,5> cap() @RULES # Ex: MS\_SQL\_Server _MSSoftware <- MS [s] _xWHITE [star s] SQL [s] _xWHITE [star s] Server [s] @@ @PRE <1,1> cap() <3,3> cap() @RULES # Ex: MS\_VB _MSSoftware <- MS [s] _xWHITE [star s] VB [s] @@ @PRE <1,1> cap() <3,3> cap() <5,5> cap() @RULES # Ex: MS\_Visual\_InterDev _MSSoftware <- MS [s] _xWHITE [star s] Visual [s] _xWHITE [star s] InterDev [s] @@ # Ex: MS\_Visual\_Studio _MSSoftware <- MS [s] _xWHITE [star s] Visual [s] _xWHITE [star s] Studio [s] @@ # Ex: MS\_Windows\_NT _MSSoftware <- MS [s] _xWHITE [star s] Windows [s] _xWHITE [star s] NT [s] @@ @PRE <1,1> cap() <3,3> cap() @RULES # Ex: MS\_Windows _MSSoftware <- MS [s] _xWHITE [star s] Windows [s] @@ # Ex: MS\_Word _MSSoftware <- MS [s] _xWHITE [star s] Word [s] @@
# Fetch the numeric-value of a kb attribute attrName belonging to concept concept @CODE # create a range G("range") = makeconcept(findroot(), "range"); addnumval(G("range"),"min",33); addnumval(G("range"),"min",34); addnumval(G("range"),"max",118); # access data "output.txt" << "range = " << getnumval(findvals(G("range"), "max")) - getnumval(findvals(G("range"), "min")) << "\n"; "output.txt" << numval(G("range"),"min") << "\n";
@NODES _ROOT @CHECK if (N("count",1) == G("max header")) succeed(); fail(); @POST "debug.txt" << "header: " << N("count",1) << " " << N("header",1) << "\n"; S("count") = N("count",1); S("header") = N("header",1); single(); @RULES _headerZone <- _header ### (1) _xWILD [fail=(_header _xEND)] ### (2) @@ @POST G("max header")--; if (G("max header") < 2) exitpass(); "debug.txt" << "max: " << G("max header") << "\n"; @RULES _xNIL <- _xWILD [match=(_LINE _headerZone)] _xEND @@
# Yucky way to get the semantics. Want to match the _humanName # once and get its piecy parts then. @PATH _ROOT _contactZone _LINE _humanName @CHECK if (!X("name found")) fail(); @POST X("prefixName",2) = N("$text"); @RULES _xNIL <- _prefixName @@ @CHECK if (!X("name found")) fail(); @POST X("firstName",2) = N("$text"); @RULES _xNIL <- _firstName @@ @CHECK if (!X("name found")) fail(); @POST X("middleName",2) = N("$text"); @RULES _xNIL <- _middleName @@ @CHECK if (!X("name found")) fail(); @POST X("lastName",2) = N("$text"); @RULES _xNIL <- _lastName @@ @CHECK if (!X("name found")) fail(); @POST X("suffixName",2) = N("$text"); @RULES _xNIL <- _suffixName @@
# Count nouns with variable "number" with value "plural" @PRE <1,1> vareq("number","plural"); @POST ++G("count plural nouns"); @RULES _xNIL <- _noun @@
@PATH _ROOT _attrBlock _attr @POST X("attr",2) = N("$text",1); @RULES _xNIL <- _xALPHA \" _xEND @@
@NODES _ROOT @POST "output.txt" << "\n\n"; @RULES _xNIL <- _BLANKLINE ### (1) @@ @POST "output.txt" << "\n"; @RULES _xNIL <- _NEWLINE ### (1) @@ @POST "output.txt" << " ''"; @RULES _xNIL <- _italics ### (1) @@ @POST "output.txt" << " '''"; @RULES _xNIL <- _bold ### (1) @@ @POST "output.txt" << " '''"; @RULES _xNIL <- _emph ### (1) @@ @POST "output.txt" << "# " << N("$text") << "\n"; @RULES _xNIL <- _itemNum ### (1) @@ @POST "output.txt" << "==Abstract==\n"; @RULES _xNIL <- _beginAbs ### (1) @@ @POST "output.txt" << N("text"); @RULES _xNIL <- _text ### (1) @@ @POST if (N("type") == "section") { "output.txt" << "==" << N("title") << "=="; } else if (N("type") == "subsection") { "output.txt" << "===" << N("title") << "==="; } else if (N("type") == "subsubsection") { "output.txt" << "====" << N("title") << "===="; } @RULES _xNIL <- _section ### (1) @@ @POST "output.txt" << "<figure id=\"" << N("label") << "\">\n"; L("filename") = figureImageFilename(N("image")); "output.txt" << "[[Image:" << L("filename") << "|thumbnail|300px|<caption>" << N("caption") << "</caption>]]" << "\n"; "output.txt" << "</figure>"; @RULES _xNIL <- _figure ### (1) @@ @POST if (N("ref type") == "eq") { L("number") = getEquationNumber(N("ref")); "output.txt" << L("number"); } else { "output.txt" << " <xr id=\"" << N("full") << "\"/> "; } @RULES _xNIL <- _ref ### (1) @@ @POST L("body") = getRefereceBody(N("cite")); #"output.txt" << " <ref>" << L("body") << "</ref> "; "output.txt" << " <ref>" << "moose" << "</ref> "; @RULES _xNIL <- _cite ### (1) @@ @POST if (N("name")) { L("con") = findEquation(N("name")); L("equations") = findattr(L("con"),"equations"); if (L("equations")) L("value") = attrvals(L("equations")); L("number") = getnumval(findvals(L("con"), "number")); "equation.txt" << "Equ out num: " << L("number") << "\n"; } if (N("full") || N("split")) { L("first") = 1; while (L("value")) { L("equ") = cleanEquation(getstrval(L("value"))); if (!L("first") && N("split")) "output.txt" << "<br><math>" << L("equ") << "</math>"; else "output.txt" << "<br><math>(" << L("number") << ")\\ \\ " << L("equ") << "</math>"; if (N("split")) "output.txt" << "<br>"; "output.txt" << "\n"; L("value") = nextval(L("value")); L("first") = 0; } } else { "output.txt" << "<math>" << N("equation") << "</math> "; } @RULES _xNIL <- _equation ### (1) @@ @POST "output.txt" << " <math display=\"inline\">" << N("equation") << "</math> "; @RULES _xNIL <- _equationInline ### (1) @@
@CODE sortchilds(G("caps")); DisplayKB(G("caps"),2); sortchilds(G("names")); DisplayKB(G("names"),2); DisplayKB(G("parse"),2); DisplayKB(G("verbs"),2); @@CODE
@NODES _LINE @PRE <1,1> cap(); <3,3> cap(); @RULES # Ex: Academic\_Publications _PublicationsHeaderPhrase [layer=(_header )] <- Academic [s] _xWHITE [star s] Publications [s] @@
# Add named node at end of con's phrase. L("return_con") = addcnode(L("con"), L("name"));
@NODES _LINE @POST S("text") = N("$text",3); single(); @RULES _link <- \[ ### (1) \[ ### (2) _xWILD [plus fail=(\])] ### (3) \] ### (4) \] ### (5) @@