text
stringlengths
22
301k
@NODES _equation @POST "debug.txt" << "addEquationToLabel 1\n"; if (!X("split")) { group(3,3,"_equation"); X("full") = N("label full",2); X("label") = N("label type",2); X("name") = N("label name",2); X("equation") = N("$text",3); addEquationToLabel(N("label name",2),N("$text",3)); } @RULES _xNIL <- _begin...
@NODES _ROOT @POST excise(1,1); noop(); @RULES _xNIL <- _xBLANK ### (1) @@
@NODES _LINE @PRE <1,1> cap(); @RULES _phoneWorkPhrase [] <- _xWILD [min=1 max=1 s layer=(_Work) match=(Office W Work)] \: [s] _xWHITE [star s] _phoneNumber [s] @@
@NODES _ROOT @POST S("text") = N("$text",3); S("type") = "text"; singler(3,3); @RULES _text <- _xWILD [matches=(_section _figure _ref _cite)] ### (1) _NEWLINE [s] ### (2) _xWILD [s plus fails=(_spacing _beginAbs _endAbs _figure _text _ref _cite _BLANKLINE _IGNORE _FOOTER _stopper _equation ...
@PATH _ROOT _td @PRE <2,2> uppercase(); @POST X("suffix",2) = strtolower(N("$text",2)); @RULES _xNIL <- \> _xALPHA \< @@
@NODES _ROOT # LINK TO SPECIAL RULE ELEMENTS: # http://visualtext.org/help/NLP_PP_Stuff/Special_rule_elements.htm @RULES _xNIL <- _xSTART ### (1) <==== REQUIRES THE NEXT NODE TO BE THE FIRST _xALPHA ### (2) _xNUM ### (3) _xWILD ### (3) _xWHITE ### (4) _xCAP ### (5) _xCAPLET ### (6) _xLET ### (7) _xE...
@PATH _ROOT _paragraph _sentence @CHECK ## FIND LAST MATCHING OBJECT S("exit") = 0; N("anaphora") = 0; S("sentence object") = prev(X("object")); if (!N("action")) fail(); # LOOP BACK THROUGH SENTENCES while (!S("exit") && S("sentence object")) { N("object") = down(S("sentence object")); # LOOP THRO...
@NODES _ROOT # Suggested Element Modifers # http://visualtext.org/help/NLP_PP_Stuff/Suggested_element_modifiers.htm # s / singlet : search below a matched node # base : makes the current node the bottom most of the search # unsealed : open up a base node to search underneath @RULES _stillMatches <- of [s] ### (1) ...
@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. ##############...
@PATH _ROOT _paragraph _sentence @RULES _departmentOf <- department _of @@ _agency <- bureau of alcohol \, [opt] tobacco and firearms @@
@NODES _ROOT #@CHECK #if (N("pattern",1) != "n") # fail(); @PRE <1,1> var("header"); @POST S("text") = N("$text",1); single(); @RULES _header <- _LINE ### (1) @@
@NODES _LINE @PRE <1,1> cap(); @RULES # Ex: Mount _cityMod <- _xWILD [min=1 max=1 s match=("Mount" "City" "Falls" "Port" "Springs" "River" "New" "Saint" "Valley" "Meadow" "Lake" "Forks" "Acres" "Beach" "Bay" "Hill" "Hills" "Park" "North" "East" "South" "West" "Rock" "La" "San" "Square" "Heights" "Green" "Summit" "...
############################################### # FILE: Numeric Lists.pat # # SUBJ: Recognized coordinate NPs built from # # numbers # # AUTH: Paul Deane # # CREATED: 01/Mar/01 # DATE OF THIS VERSION: 31/Aug/01 # # C...
@CODE L("hello") = 0; @@CODE #@PATH _ROOT _TEXTZONE _tok @NODES _tok # num . num @POST xrename("_num"); X("num") = N("$text",2) + "." + N("$text",4); @RULES _xNIL <- _xSTART _xNUM \. _xNUM _xEND @@ # num / num @POST xrename("_num"); X("num") = 1; X("fraction") = 1; @RULES _xNIL <- _xSTART _xNUM \...
@NODES _ROOT @POST if (num(N("words")) && num(N("words")) == num(N("caps"))) { L("phrase") = strtrim(strsubst(strtolower(N("$text",1)),":",0)); "output.txt" << L("phrase") << "\n"; L("con") = getconcept(G("heads"),L("phrase")); IncrementCount(L("con"),"count"); addstrval(L("con"),"file",G("$inputname")); ...
@DECL ############################################### # General functions ############################################### AddUniqueCon(L("concept"),L("name")) { L("con") = findconcept(L("concept"),L("name")); if (!L("con")) L("con") = makeconcept(L("concept"),L("name")); return L("con"); } AddUniqueStr(L("concep...
@CODE DisplayKB(G("RadLex"), 1); @@CODE
@NODES _StartingTag @RULES _Attribute <- _xWILD [s one matches=("_xALPHA" "_" ":")] ### (1) _xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (2) _whiteSpace [opt] ### (3) \= [one] ### (4) _whiteSpace [opt] ### (5) _PubidLiteral [one] ### (6) @@ _Attribute <- _xWILD [s o...
@NODES _LINE @RULES _honors <- graduated [s opt] _xWHITE [s opt] with [s opt] _xWHITE [s opt] _xWILD [s t min=1 max=1 matches=( honors )] @@ _honors <- magna [s] _xWHITE [s] cum [s] _xWHITE [s] laude [s] @@ _honors <- summa [s] _xWHITE [s] cum [s] _xWHITE [s] laude [s] @@...
# Check if a string is is terminated by the given substring @POST if (!strendswith(N("$text",1),"ing")) fail(); @RULES _ving <- _verb @@
@CODE DisplayKB(G("dict"),0); L("con") = down(G("dict")); L("vals") = AttrValues(L("con"),"pos"); L("last") = 0; while (L("con")) { L("word") = conceptname(L("con")); L("letter") = strpiece(L("word"),0,0); if (!L("last") || L("letter") != L("last")) { L("filename") = str(DictionaryFilename(L("word"),"pos")); ...
@PATH _ROOT _attr _attrConcept _LINE @POST X("attribute",2) = N("word",1); @RULES _xNIL <- _string _xEND @@
# Replace named attribute's value(s) with str. replaceval(L("con"), L("name"), L("str"));
# Match _det _quan _adj _noun nodes, starting with _noun. Reduce to _np @RULES _np <- _det _quan _adj _noun [trigger] @@
@CODE G("format") = getconcept(findroot(),"format"); G("caps") = getconcept(findroot(),"caps"); G("names") = getconcept(findroot(),"names"); @@CODE
# Check if the entire string is uppercase @CHECK if (striscaps(N("$text",1))) fail(); @RULES _name <- will @@
@NODES _ROOT @RULES _xNIL <- the ### (1) @@
@NODES _cities @POST L("cities") = getconcept(G("state"),"cities"); L("city") = makeconcept(L("cities"),N("$text",1)); L("num") = strsubst(N("$text",3),",",0); addnumval(L("city"),"population",num(L("num"))); G("cities") << strtolower(N("$text",1)) << " s=city state=" << QuoteIfNeeded(conceptname(G("state"))) <<...
@NODES _ROOT @POST L("text") = conceptname(pnvar(N(1), "code")); if (strcontains("-", L("text"))) { L("range") = split(L("text"), "-"); S("class_start") = L("range")[0]; L("class_end") = L("range")[1]; L("class_end") = split(L("class_end"), "."); S("class_end") = L("class_end")[0]; makeconcept(pnvar(N(1), "code...
@NODES _LINE @POST singler(2,2); @RULES _item <- _xSTART ### (1) _xWILD [fail=(_comma)] ### (2) @@ @POST singler(2,2); @RULES _item <- _comma ### (1) _xWILD [plus fail=(_item _comma)] ### (2) @@
@DECL ############################################### # General functions ############################################### AddUniqueCon(L("concept"),L("name")) { L("con") = findconcept(L("concept"),L("name")); if (!L("con")) L("con") = makeconcept(L("concept"),L("name")); return L("con"); } AddUniqueStr(L("concep...
@PATH _ROOT _educationZone # Mark the start of subzone in parse tree. @CHECK #Ngt(1,"instance",0) if (N("instance",1) <= 0) fail(); @RULES _eduStart <- _LINE [s] @@
@CODE L("filename") = G("$apppath") + "\\input\\pickins.txt"; "debug.txt" << L("filename") << "\n"; if (!G("$isdirrun") || G("$isfirstfile")) { G("out") = openfile(L("filename")); } else { G("out") = openfile(L("filename"),"app"); } @@CODE
@PATH _ROOT _termEntry _base @POST excise(1,1); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@DECL ############################################### # General functions ############################################### AddUniqueCon(L("concept"),L("name")) { L("con") = findconcept(L("concept"),L("name")); if (!L("con")) L("con") = makeconcept(L("concept"),L("name")); return L("con"); } AddUniqueStr(L("concep...
# Send output to standard output or user-supplied stream @CODE # In VisualText, output to a file.  Outside VisualText, output to user-supplied stream. if (interactive())    G("out") = "out.txt"; else    G("out") = cout(); G("out") << "Hello output stream!" << "\n"; @@CODE
@PATH _ROOT _paragraph _sentence @POST L("con") = AddOrder(N(1),X("sent",3)); pncopyvars(N(1),L("con")); @RULES _xNIL <- _xWILD [one match=(_name _have _for _money _buy _acquire _date _anaphora)] @@
@PATH _ROOT _edge @RULES _child <- _x ### (1) @@
# Convert string to XML or HTML string "output.txt" << xmlstr("hello&bye") << "\n"; Outputs: hello&amp;bye
@CODE SaveKB("format.kbb",G("format"),2); SaveKB("everything.kbb",findroot(),2); @@CODE
@NODES _ROOT @POST L("leaf") = pndown(N(1)); pnmakevar(L("leaf"), "stop", 1); splice(1,1); @RULES _xNIL <- _stop ### (1) @@
@NODES _LINE @PRE #<8,8> length(5); <10,10> length(4); <13,13> cap(); @RULES # Ex: Newt\_York,\_NY,\_ _cityStateZip <- _city [s layer=(_cityName)] \, [s opt] _xWHITE [star s] _state [one s layer=(_stateName)] \. [s opt] \, [s opt] _xWHITE [star s] _xNUM [s layer=(_zipCode)] \- [s opt] _xNUM [s opt layer=(_...
@NODES _LINE @POST S("con") = N("$text",2); X("con") = N("$text",2); single(); @RULES _con <- \" ### (1) _xWILD [fail=(_xEND)] ### (2) @@
@DECL ######## # FUNC: ADVLREGISTER # SUBJ: Register an adverbial in the kb. # INPUT: # OUTPUT: # NOTE: For adverbials not attached to a clause, eg, at the # start of a sentence. # Register for subsequent clauses. # Check for prior clauses. ######## advlregister( L("anode"), # Adverbial node...
@NODES _ROOT @POST S("con") = makeconcept(G("word"),N("header",1)); addstrval(S("con"),"language",N("header", 1)); single(); @RULES _language <- _headerZone ### (1) @@
# Find entire path of dictionary concept for the given string. (If not present, don't add the word.) L("return_str") = findwordpath(L("str"));
@NODES _ROOT @PRE <1,1> var("start"); <7,7> var("end"); @RULES _attr <- _LINE ### (1) _LINE [group="_concept"] ### (2) _LINE ### (3) _LINE [group="_attrConcept"] ### (4) _LINE [group="_type"] ### (5) _LINE [group="_value"] ### (6) _LINE ### (7) @@
@DECL ############################################### # General functions ############################################### AddUniqueCon(L("concept"),L("name")) { L("con") = findconcept(L("concept"),L("name")); if (!L("con")) L("con") = makeconcept(L("concept"),L("name")); return L("con"); } AddUniqueStr(L("concep...
@DECL ############################################### # General functions ############################################### AddUniqueCon(L("concept"),L("name")) { L("con") = findconcept(L("concept"),L("name")); if (!L("con")) L("con") = makeconcept(L("concept"),L("name")); return L("con"); } AddUniqueStr(L("concep...
@NODES _LINE @RULES _word <- _xWILD [match=(_xALPHA _xNUM \.)] @@
# Rename every node that matched the current element to NAME @RULES _locfield <- location \: _xWILD [rename=_location] \n @@
@NODES _LINE @POST X("indent") = 0; @RULES _indent <- _xSTART ### (1) \" ### (2) @@ @POST singler(2,2); @RULES _indent <- _xSTART ### (1) _xWILD [match=(_xWHITE)] ### (2) \" ### (3) @@
# Replace named attribute's value(s) with num. replaceval(L("con"), L("name"), L("num"));
@CODE L("hello") = 0; @@CODE @NODES _clause # there vg @POST if (pnname(N(2)) == "_np") L("n") = pndown(N(2)); else L("n") = N(2); chpos(L("n"),"EX"); # there/EX [DEFAULT] if (pnname(N(4)) == "_vg") if (!N("voice",4)) X("voice") = N("voice",4) = "active"; @RULES _xNIL <- _xWILD [star match=(_...
@NODES _LINE @POST singler(1,1); @RULES _countryText <- _xWILD [fail=(_codes)] _codes ### (1) @@
@PATH _ROOT _experienceZone _experienceInstance _LINE # If date range wasn't picked up, try single date. # @CHECK if (X("date range",3)) fail(); @POST X("date range",3) = N("$text",1); @RULES _xNIL <- _SingleDate [s] @@ # If city state hasn't been picked up yet and there's a cap turd, # pick it up. @CHECK if ( ...
# THIS COMES FROM: # https://conjugator.reverso.net/conjugation-portuguese-verb-ser.html @CODE L("nothing") = 0; @@CODE
@PATH _ROOT _derivedTerms _headerZone _LINE @POST addstrval(N("con",1),"derivedTerms",N("$treetext",1)); @RULES _xNIL <- _derivedTerm ### (1) @@
@DECL DictDisplayAttr(L("con"),L("attr")) { L("vals") = AttrValues(L("con"),L("attr")); L("str") = L("attr") + "="; L("count") = ValCount(L("vals")); if (L("count") > 1) L("str") = L("str") + "["; L("first") = 1; while (L("vals")) { L("val") = getstrval(L("vals")); if (!L("first")) L...
@NODES _LINE @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@NODES _ROOT @POST N("thisone",3) = 1; @RULES _xNIL <- this [s] ### (1) one ### (2) _xALPHA ### (3) @@ @POST S("thisone") = 1; single(); @RULES _this <- that [s] ### (1) one ### (2) _xALPHA ### (3) @@ @POST singler(2,3); @RULES _two <- which ### (1) one ### (2) _xALPHA ### (3) @@ @POST L("und...
# Find the numth node in phrase. L("return_con") = findnode(L("phrase"), L("num"));
@NODES _LINE @PRE <1,1> cap(); @RULES # Ex: Certificates _OtherHeaderWord [layer=(_headerWord )] <- _xWILD [min=1 max=1 s match=("Certificates" "Patents" "Affiliations")] @@
@CODE DictionaryStart(); @@CODE
# Fetch concept, given the path str. L("return_con") = pathconcept(L("str"));
@PATH _ROOT _doctypedecl _EntityDecl @POST S("public")=1 ; S("URI") = N("textValue",3) ; single() ; @@POST @RULES _ExternalID <- _xWILD [min=1 max=1 matches=("PUBLIC")] ### (1) _whiteSpace [one] ### (2) _PubidLiteral [one] ### (3) _whiteSpace [one] ### (4) _PubidLiteral [one] ### (5) @@ _...
@CODE #fileout("caps.txt") prlit("caps.txt", "INFO FOR CAPITALIZED PHRASES\n"); prlit("caps.txt", " (Experience zone only)\n"); prlit("caps.txt", "Formula: Job conf=TOTLEN+CAPLEN+JOBNUM*3+JOBEND*10\n"); prlit("caps.txt", "=======================================================\n"); prlit("caps.txt", " TOT CAP UNK JOB ...
@CODE L("hello") = 0; @@CODE @NODES _sent # np alpha alpha dqan @CHECK if (!N("verb",3)) fail(); @POST L("tmp3") = N(3); L("tmp4") = N(4); group(3,3,"_verb"); pncopyvars(L("tmp3"),N(3)); L("v") = N(3); group(3,3,"_vg"); mhbv(N(3),L("neg"),0,0,0,0,L("v")); pncopyvars(L("tmp3"),N(3)); N("verb ...
@NODES _LINE @RULES _date <- _xNUM ### (1) \/ ### (2) _xNUM ### (3) @@ @PRE <1,1> var("month"); <2,2> var("year"); @RULES _newNode <- _xALPHA ### (1) _xNUM ### (2) to ### (3) present ### (4) @@
@DECL ############################################### # General functions ############################################### AddUniqueCon(L("concept"),L("name")) { L("con") = findconcept(L("concept"),L("name")); if (!L("con")) L("con") = makeconcept(L("concept"),L("name")); return L("con"); } AddUniqueStr(L("concep...
@NODES _ROOT @POST N("text") = N("$treetext"); @RULES _xNIL <- _td ### (1) @@
@NODES _td @RULES _tag <- \< ### (1) _xWILD [fail=(\>)] ### (2) \> @@
# create a concept like noun and assign it as the value of a word's attribute. First, create the concepts named words and noun as children to the root of the KB (concept), and then make the concept book a child of words G("words") = makeconcept(findroot(), "words"); G("noun") = makeconcept(findroot(),"noun"); G("noun...
@NODES _ROOT @PRE <1,1> var("word"); <1,1> var("female"); <1,1> var("male"); @POST "both.txt" << N("word") << " " << N("example") << "\n"; @RULES _xNIL <- _LINE ### (1) @@
@NODES _sentence @PRE <1,1> cap(); <2,2> cap(); @RULES # Ex: MD\_Files _company <- MD [s] Files [s] @@ @PRE <1,1> cap(); <2,2> cap(); <3,3> cap(); @RULES # Ex: New\_Hampshire\_Medical _company <- New [s] Hampshire [s] Medical [s] @@ @PRE <1,1> cap(); <2,2> cap(); @RULES # Ex: Carezani\_Med _company <- Carezani [s...
# Fetch the number from a numeric value @CODE # create a range G("range") = makeconcept(findroot(), "range"); addnumval(G("range"),"min",33); addnumval(G("range"),"max",118); # access data "output.txt" << "range = " <<   getnumval(findvals(G("range"), "max")) -   getnumval(findvals(G("range"), "min")) << "\n"; # clean...
@PATH _ROOT _LINE _list @POST excise(1,1); @RULES _xNIL <- _curly ### (1) @@
@PATH _ROOT _row @RULES _header <- _thStart ### (1) _xWILD [fail=(_thEnd)] ### (2) _thEnd ### (3) @@ @RULES _column <- _tdStart ### (1) _xWILD [fail=(_tdEnd)] ### (2) _tdEnd ### (3) @@
@PATH _ROOT _attr _value _LINE @POST X("value",2) = N("word",1); @RULES _xNIL <- _string _xEND @@
@NODES _ROOT @POST G("record count")++; S("record name") = "record" + str(G("record count")); S("record con") = makeconcept(G("records con"),S("record name")); single(); @RULES _RECORD <- _xWILD [plus fails=(_lineTerminator) except=(_FIELDS)] ### (1) _xWILD [one match=(_lineTerminator _xEND)] ### (2)...
# Remove dictionary concept wordString from the KB dictionary hierarchy @CODE "output.txt" << "1 " << conceptname(addword("hello")) << "\n"; "output.txt" << "2 " << conceptname(wordindex("hello")) << "\n"; "output.txt" << "3 " << findwordpath("hello") << "\n"; "output.txt" << "4 " << findwordpath("olleh") << "\n"; "o...
# Convert string to SQL format "output.txt" << sqllstr("hello'bye") << "\n"; Outputs: hello''bye
@CODE DisplayKB(G("pred_codes"),1); sumRanks(down(G("pred_diagnoses"))); sumRanks(down(G("pred_procedures"))); convertToInt(down(G("pred_diagnoses")), 100); convertToInt(down(G("pred_procedures")), 100); G("procedure_pred_list"); G("diagnosis_pred_list"); L("proc_code_cons") = getChildCons(G("pred_procedures"), 0);...
# Move a concept childConcept before previous sibling (Moves the concept to the 'left' or 'higher' in the pecking order.) @CODE "output.txt" << "move\n"; G("alpha") = makeconcept(findroot(),"first"); G("beta") = makeconcept(findroot(),"second"); G("gamma") = makeconcept(findroot(),"third"); movecleft(G("gamma")); mov...
@NODES _ROOT @POST S("section_title") = N("$text", 1); excise(4,4); excise(1,2); single(); @RULES _section <- _xWILD [fails=(\: _break)] ### (1) \: ### (2) _xWILD [fails=(_break _xEND)] ### (3) _xWILD [one matches=(_break _xEND)] ### (4) @@ @RULES _looseText <- _xWILD [fails=(_section _break)] @...
# Reduce the _det and _noun to an _np.. REMOVE the node that matched element 3 from the parse tree @POST singlex(1,2); @RULES _np <- _det _noun _xWILD [one fail=(_noun)] @@
@PATH _ROOT _LINE @CHECK if ( (N("hi class",1) == N("hi class",5)) && ((N("hi conf",1) >= G("threshold")) || (N("hi conf",5) >= G("threshold"))) ) succeed(); fail(); @POST # Want a merge variant that keeps everything as is between the # two nodes. Could add a boolean to it. S("hi class") = N("h...
# @NODES _REZZONE @PATH _ROOT _contactZone # 10/19/99 AM. # @NODES _contactZone # # DON'T SEAL? @RULES _addressBlock <- _addressPart [tree] _xWILD [tree star match=(_addressPart _BLANKLINE _horizRule)] @@ # So using TREE instead of SINGLET. _addressBlock <- _addressPart [tree min=1 max=10] @@ # because it does...
# This will match words such as junk, junks, junky, junkyard @PRE <1,1> regexp("junk*"); @POST group(1,1,"_junkword"); @RULES _xNIL <- _xALPHA @@
@CODE DisplayKB(G("words"), 1); @@CODE
# Fetch the name of an knowledge base attribute G("myConcept") = makeconcept(findroot(),"a concept"); G("myAttr") = addattr(G("myConcept"),"an attribute"); "output.txt" << attrname(G("myAttr")) << "\n";
@CODE if (!G("pretagged")) exitpass(); @@CODE @MULTI _ROOT # Highlight mismatches to pretagged text. @POST noop(); @RULES _xNIL <- _poserr @@
@NODES _LINE @PRE <1,1> cap(); <3,3> cap(); <5,5> cap(); @RULES # Ex: Senior\_Software\_Engineer _jobTitle [layer=(_Caps )] <- Senior [s] _xWHITE [star s] Software [s] _xWHITE [star s] Engineer [s] @@ @PRE <1,1> cap(); <3,3> cap(); @RULES # Ex: Network\_Technician _jobTitle [layer=(_Caps )] <- Network [s] _xWHITE [...
@NODES _ROOT @POST "headerzone.txt" << N("text",1) << "\n\n"; S("header") = N("text",1); single(); @RULES _headerZone <- _header ### (1) _xWILD [plus fail=(_header _bottom)] ### (2) @@
# Rename concept aConcept with new name newConceptNameStr if(findconcept(findroot(),"apples")) rmconcept(findconcept(findroot(),"apples")); G("apples") = makeconcept(findroot(),"apples"); addstrval(G("apples"),"have","seeds"); renameconcept(G("apples"),"fruit"); "output.txt" << conceptname(G("apples")) << "\n";
@PATH _ROOT _educationZone _educationInstance _LINE @POST if (!X("city",3)) X("city",3) = N("$text"); # noop() @RULES _xNIL <- _city [s] @@
@NODES _humanNameCandidate @RULES _addressPart <- _humanName @@
# Reduce the _det and _noun to an _np, but not the node that matched element 3 @POST  singler(1,2); @RULES _np <- _det _noun _xWILD [one fail=(_noun)] @@
@CODE # Add all euis in eui_to_codes to P_euis, with count attr L("eui_iter") = G("eui_to_codes") @@CODE
@PATH _ROOT _LINE @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@