text
stringlengths
22
301k
# Remove concept's children and phrase. rmchildren(L("con"));
@CODE # G("outfile") = G("$inputfilename"); # Todo! fileout("xml.txt") prlit("xml.txt", " <?xml version=\"1.0\" ?>\n") prlit("xml.txt", "<BizTalk xmlns=\"urn:schemas-biztalk-org/biztalk-0.81.xml\">\n") prlit("xml.txt", " <Body>\n") prlit("xml.txt", " <Resume xmlns=\"urn:schemas-biztalk-org:HR-XML-org/Resume\">\n") p...
@NODES _ROOT @RULES _report <- _xWILD[fails=(_addendum)] @@
@CODE G("radlex") = findconcept(findroot(),"radlex"); if (!G("radlex")) G("radlex") = makeconcept(findroot(),"radlex"); rmchildren(G("radlex")); @@CODE
# Free the statement handle for the currently open database @CODE dbopen("test","root","mypassword"); dballocstmt(); dbexecstmt("INSERT INTO employee (name, age) VALUES('John Smith','32');"); dbfreestmt(); dbclose(); @@CODE
@NODES _ROOT @POST noop(); @RULES #===================== Quoted Empty Items ===================== _xNIL <- _emptyItem [layer=(_item)] ### (1) _xWILD [one lookahead match=(_separator _lineTerminator)] ### (2) @@ #================ First Non-Enclosed Empty Items ============== _xNIL <- _lineTermina...
@NODES _LINE @RULES _indent <- _xWILD [match=(_space)] ### (1) @@
# Remove a concept's phrase. rmcphrase(L("con"));
@DECL # indent # params # f: file to which to print # n: integer number of tabs to print # return # null indent(L("f"), L("n")) { L("i") = 0; while (L("i") < L("n")) { L("f") << "\t"; L("i")++; } } printQuotedStr(L("f"), L("str")) { L("f") << "\"" << L("str") << "\""; } # print...
@NODES _ROOT @POST excise(3,4); excise(1,1); single(); @RULES _termEntry <- \{ ### (1) _xWILD [fails=(\})] ### (2) \} ### (3) _xWILD [opt matches=(\n \r)] @@
@PATH _ROOT _textZone _LINE @RULES _pessoa <- _xWILD [one match=(primeira segunda terceira)] @@ @RULES _numero <- _xWILD [one match=(singular plural)] @@ #@RULES _tempo <- pretérito _xWILD [one match=(imperfeito perfeito)] @@ #@RULES _tempo <- pretérito mais \- que \- perfeito @@ @RULES _tempo <- pretérito @@ @RULES...
@NODES _FIELDS @POST makeconcept(G("fields con"),N("value")); @RULES _xNIL <- _item ### (1) @@
@CODE DisplayKB(G("words"),1); @@CODE
@NODES _paragraph @RULES _sentence <- _xWILD [fail=(_endSent _BLANKLINE)] ### (1) _xWILD [one match=(_endSent _BLANKLINE)] ### (2) @@
# Specify the maximum number of nodes to match @RULES _htmltag <- \< _xWILD [min=1 max=100] \> @@
@DECL ############## # LOOKUPWORD # SUBJ: Lookup and record word information. ############## lookupword(L("n")) { if (!L("n")) return; L("txt") = pnvar(L("n"),"$treetext"); L("lctxt") = strtolower(L("txt")); if (strisupper(strpiece(L("txt"),0,0))) pnreplaceval(L("n"),"cap",1); # 06/26/06 AM. L("wcon") = dictfind...
@NODES _ROOT @POST S("con") = N("con", 1); excise(1,1); single(); @RULES _split <- _split _entry [plus] ### (1) @@
@NODES _ROOT @RULES _compare <- _xWILD [match=(more less greater less)] ### (1) than ### (2) @@
# Add concept value con_val to concept's name attribute. addconval(L("con"), L("name"), L("con_val"));
@NODES _paragraph @POST splice(1,1); @RULES _xNIL <- _LINE ### (1) @@
@PATH _ROOT _paragraph _sentence @POST N("date",5) = makeconcept(N("action",5),"date"); addstrval(N("date",5),"year",N("$text",2)); @RULES _xNIL <- _prep [s] ### (1) _year [s] ### (2) alone [s] ### (3) _conj [s] ### (4) _event [s] ### (5) @@
@NODES _ROOT @POST excise(5,5); S("code") = AddUniqueCon(G("icd_codes"), N("$text", 1)); addstrval(S("code"), "term", N("$text", 1)); excise(1,3); single(); # Here we group individual icd entries (one per line), # delete beginning and end quotes, if they exist, # and extract codes and terms. @RULES _code <- _xNUM ...
@NODES _LINE @RULES _CompleteSchoolName [] <- The _xWHITE [star s] _SchoolNamePhrase @@
# Find concept number num under the parent concept con. L("return_con") = findconcept(L("con"), L("num"));
@NODES _LINE @POST singler(1,5); # Reduce all but the trailing whitespace. @RULES _url <- _xALPHA [layer=(_protocol)] \: [s trigger] \/ [s] \/ [s] _xWILD [plus fails=(\, _xWHITE _whtSEP \[ \])] _xWILD [opt s match=(_xWHITE _whtSEP)] @@
@CODE L("hello") = 0; @@CODE #@PATH _ROOT _TEXTZONE _sent _seg @NODES _seg # alpha alpha alpha. # Could still want to allow first or last to be separated as # a verb. @CHECK if (X("resolve") != "np") fail(); @POST fixnpnonhead(2); fixnpnonhead(3); xrename("_np"); # fixnphead L("tmp4") = N(4); grou...
# Determine whether apple can be yellow, red or blue color, print to output.txt in the form 1) are apples <color>? <true or false>, etc. "output.txt" << "1) are apples yellow? " << attrwithval(G("apple"), "color", "yellow") << "\n"; "output.txt" << "2) are apples red? " << attrwithval(G("apple"), "color", "red") << "\...
@NODES _ROOT @POST L("text") = N("$text",2); if (strendswith(L("text"),"ing") && N("verb",2) && N("noun",2)) { pnrename(N(2),"_noun"); } @RULES _xNIL <- _noun ### (1) _ambig ### (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...
############################################### # FILE: XML SubSchema.pat # # SUBJ: Put together the major blocks of an # # XML Document # # AUTH: Paul Deane # # CREATED: 14/Jan/01 # DATE OF THIS VERSION: 31/Aug/01 # # C...
@CODE prlit("edu.txt", "DUMP EDUCATION INSTANCES\n"); prlit("edu.txt", "------------------------\n"); @@CODE @PATH _ROOT _educationZone _educationInstance _LINE _educationPart @POST ndump("edu.txt",1); # prlit("edu.txt","-------------\n"); "edu.txt" << "--------------\n"; noop(); @RULES _xNIL <- _Grade @@
@PATH _ROOT _LINE @POST if (N("fields",5)) N("minor conf",5) = 95; else N("minor conf",5) = 90; # Override whatever was assigned to this cap phrase. N("hi class",5) = "minor"; N("hi conf",5) = N("minor conf",5); # Still room to grow! # noop() @RULES #example "Minored in English" _xNIL <- _minorK...
################################################## # FILE: SIMPLE_NUMERICS.pat # # SUBJ: Analyse simple numeric words as numerals # # AUTH: Paul Deane # # CREATED: 04/Jan/01 # DATE OF THIS VERSION: 31/Aug/01 # # Copyright ########################...
# Increment the count of nouns,. without reducing _noun to anything @CHECK ++G("noun count"); @POST  noop();  # If absent, then _noun will reduce to _xNIL. @RULES _xNIL <- _noun @@
@PATH _ROOT _pronunciations _headerZone _LINE @POST addstrval(X("pronunciation",2),"phonemic",N("$text",1)); "debug.txt" << N("$text",1) << "\n"; @RULES _xNIL <- _phonemic ### (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...
@NODES _ROOT @RULES _no <- no \. @@ _inc <- inc \. @@ _num <- _xNUM \. _xNUM @@
@NODES _ROOT @POST N("pronunciation") = makeconcept(G("word"),"pronunciation"); @RULES _xNIL <- _pronunciations ### (1) @@ @POST N("synonym") = makeconcept(G("word"),"synonym"); @RULES _xNIL <- _synonyms ### (1) @@ @POST N("derivedTerms") = makeconcept(G("word"),"derivedTerms"); @RULES _xNIL <- _derivedTer...
@PATH _ROOT _LINE @POST S("city") = N("$text",1); S("state") = N("$text",4); single(); @RULES _cityState <- _city [s layer=(_cityName)] \, [s] _xWHITE [s star] _state [s layer=(_stateName)] @@ @CHECK if ( N("len",1) <= 2 && !N("capofcap",1) && !N("capandcap",1) && (N("city conf",1) >= 40 || N(...
# Match _det _quan _adj _noun sequence and reduce to _np, matching _noun first @RULES _np <- _det _quan _adj _noun [t] @@
################################################ # FILE: Numeric Sequences.pat # # SUBJ: Recognize numeric sequence expressions # # like 5-15, or between 5 and 15 # # AUTH: Paul Deane # # CREATED: 01/Mar/01 # DATE OF THIS VERSION: 31/Aug/01 ...
@NODES _LINE @POST xaddlen("nindent", 2) singler(2,2) # 10/09/99 AM. @RULES # Count indentation separately. Doesn't add to nonwhite blob count. _whtINDENT <- _xSTART _xWHITE [s plus]@@ # Recording long blobs of whitespace now. # @POST xinc("nblobs") single() # 10/09/99 AM. @RULES # Note: Blobs = nonwhite ...
@PATH _ROOT _RULES @POST rfaelement(1, 2) single() @RULES _ELEMENT [base] <- _NONLIT _PAIRS @@ _ELEMENT [base] <- _LIT _PAIRS @@ _ELEMENT [base] <- _NUM _PAIRS @@
@PATH _ROOT _educationZone _educationInstance _LINE _school # If city or state found within a school, prefer that. # OVERWRITES city,state from elsewhere in education instance, if present. @POST X("city",3) = N("$text"); @RULES _xNIL <- _city [s] @@ @POST X("state",3) = N("$text"); @RULES _xNIL <- _state [s] @@ ...
@CODE G("caps") = getconcept(findroot(),"caps"); G("names") = getconcept(findroot(),"names"); @@CODE
@NODES _LINE @RULES _date [] <- _monthNum [s] \/ [s one] _year [s one] @@ _date [] <- _monthNum [s] \- [s one] _year [s one] @@ @RULES # Ex: July '90 _date [] <- _monthWord [s] \. [s opt] \, [s opt] _xWHITE [s] _year [s] @@ # Ex: Summer '90 _date [] <- _season [s] \, [s opt] _xWHITE [s]...
@PATH _ROOT _paragraph _sentence @CHECK ## FIND LAST MATCHING OBJECT S("exit") = 0; N("anaphora") = 0; S("sentence object") = X("object"); if (N("action")) fail(); # LOOP BACK THROUGH SENTENCES while (!S("exit") && S("sentence object")) { N("object") = down(S("sentence object")); # LOOP THROUGH OBJ...
# Remove all phrases from a KB subhierarchy @CODE # Warning: Exit VisualText without saving, after running this example, or your Gram Tab # hierarchy will lose all its samples! G("root") = findroot(); # Get the root concept of the KB. G("gram") = findconcept(G("root"), "gram"); # Get root of Gram hierarchy. prunephr...
# Find a concept in the subhierarchy of a given concept. e.g.: G("returnedConcept") = findhierconcept("child",G("ancestor")); finds the concept named "child" anywhere under the concept pointed to by G("ancestor"). L("return_con") = findhierconcept(L("name"), L("hier"));
@PATH _ROOT _LINE _example @POST X("male",2) = 1; @RULES _xNIL <- _xWILD [one matches=(man boy male father brother uncle)] ### (1) @@
@NODES _ROOT @POST S("con") = MakeCountCon(G("word"),"pos"); single(); @RULES _posZone <- _partofspeech _xWILD [plus match=(_defZone)] ### (1) @@
@NODES _LINE @POST S("degree") = N("$text",1); S("major") = N("$text",5); single(); @RULES # bachelor(,) (of) computer engineering _degreeInMajor <- _degree [s] _xWHITE [s opt] _xWILD [s one match=(\, of \- in \:)] _xWHITE [s ] _field [s layer=(_major)] @@ # ex BS CS @POST S("degree") = N("$text",1); S...
@PATH _ROOT _group _subgroup @POST X("con",3) = MakeCountCon(X("con",2),"subgroup"); addstrval(X("con",3),"description",N("description",1)); @RULES _xNIL <- _subgroupHeader ### (1) @@
# Remove child named str from parent concept con. rmchild(L("con"), L("str"));
# Execute a statement with the currently open statement handle @CODE dbopen("test","root","mypassword"); dballocstmt(); dbexecstmt("INSERT INTO abc (name, number) VALUES('Jane','0011');"); dbexecstmt("INSERT INTO abc (name, number) VALUES('Joe','0013');"); dbfreestmt(); dbclose(); @@CODE
@PATH _ROOT _pronunciations _headerZone _LINE @RULES _phonemic <- \/ ### (1) _xWILD [plus fail=(\/)] ### (2) \/ ### (3) @@
############################################### # CONTENT INDEX # # 1. Rules for special items like ampersands # # greater than etc. plus tag elements # # 2. Signals for special tag types including # # comments and entity references # #######################...
@NODES _ROOT @POST excise(1,1); noop(); @RULES _xNIL <- _xWILD [fails=(_labelEntry _alphaNum)] ### (1) @@
@CODE "output.txt" << "[" << today() << "]" << "\n"; @@CODE @NODES _ROOT @POST excise(1,1); excise(3,3); excise(5,5); @RULES _xNIL <- \r [optional] \n \r [min=0 max=1] \n _xWILD [min=0 max=0 match=(\r \n)] @@ @POST excise(1,1); @RULES _xNIL <- \r \n @@
@CODE fileout("exp_anchors.txt"); # 06/10/00 AM. @@CODE # Look for an anchor in each line of experience zone. # Would like a way to refer to vars in the experience zone of: @PATH _ROOT _experienceZone _LINE # eg, X("var", 2) refers to var in 2nd component of path. # opt! Can reverse the list and change the numbers ac...
@NODES _LINE @RULES _state <- _xWILD [s one match=( _statePhrase _PostalState )] @@ _country <- _xWILD [s one match=( _countryPhrase _countryWord )] @@
@NODES _NLPPP # Catch the start of a function call here, so it won't be grabbed by # expression grammar. # # Added L local var reference. # @POST fncallstart() single() @RULES _VARLIST [base] <- _xWILD [s one match=( s G N X P L ) layer=(_VARNAME)] \( @@ # Eg, user::func() # @POST scopefncallstart(1,4) sin...
@PATH _ROOT _synonyms _headerZone _LINE @RULES _synonym <- _xWILD [plus match=(_xALPHA)] ### (1) @@
# Fetch attribute named str belonging to concept con. L("return_attr") = findattr(L("con"), L("str"));
@PATH _ROOT _textZone _headerZone _LINE @POST X("lang") = N("lang"); @RULES _xNIL <- _langauge @@ @POST X("pessoa",3) = X("pessoa",4); X("meaning",3) = 1; @RULES _xNIL <- _pessoa @@ @POST X("numero",3) = X("numero",4); X("meaning",3) = 1; @RULES _xNIL <- _numero @@ @POST X("tempo",3) = X("tempo",4); X("meaning",3)...
@CODE L("file") = "numbers.dict"; L("number") = down(G("numbers")); addword("numeric"); while (L("number")) { L("name") = conceptname(L("number")); L("file") << L("name") << " numermic=" << str(numval(L("number"),"numeric")) << "\n"; L("number") = next(L("number")); } @@CODE
@PATH _ROOT _experienceZone @CHECK # Require the instance to have a daterange. if (!N("date range",1)) fail(); @POST prlit("output.xml","<Position>\n"); #prlit("output.txt","Date: "); #fprintnvar("output.txt","date range",1); #prlit("output.txt","\n"); prlit("output.xml","\n<EmployerName>"); #fprintnvar("output.xml"...
@NODES _LINE @RULES # Ex: current _Present <- _xWILD [min=1 max=1 s match=("current" "date" "now" "today" "present")] @@
@PATH _ROOT _paragraph _sentence # @POST # G("out") << phrasetext() << "\n"; # @RULES # _xNIL <- # _xWILD [plus match=(_xCAP _USA)] ### (1) # bureau ### (2) # @@ @POST G("out") << phrasetext() << "\n"; @RULES _xNIL <- _xWILD [plus match=(_xCAP _USA)] ### (1) for ### (2) _xWILD [plus match=(_xC...
@PATH _ROOT _DECL _NLPPP @POST rfbdecls(1) single() @RULES _DECL [base] <- _FUNCDEF [plus] @@
@NODES _ROOT @POST group(1,2,"_COMMENT"); @RULES _xNIL <- \% ### (1) _xWILD ### (2) _xWILD [lookahead matches=(_NEWLINE _BLANKLINE)] ### (3) @@
@CODE # # Essentially iterate over pred_codes, setting # # rank(code) = max(code_ranks) # # Print results to file. # L("iter") = down(G("pred_codes")); # L("ranks") # while (L("iter")) { # L("child_attrs") = findattrs(L("iter")); # # Iterate over each attr (rank) of parent # L("curr_max") = 0.0; # ...
@MULTI _ROOT _section _sentence _subsection @PRE <2,2> vareq("negation", "POST"); @POST excise(1,2); # single(); @RULES _xNIL <- _xWILD [min=0 max=5 matches=(_xALPHA _xNUM _conj _phrase _patientID \, \-)] _negation @@ @PRE <1,1> vareq("negation", "PREN"); @POST excise(1,2); # single(); @RULES _xNIL <- _negat...
@NODES _LINE @POST X("con") = makeconcept(G("codes"),N("$text",1)); X("word count") = 0; @RULES _xNIL <- _code ### (1) @@ @POST L("word") = strtolower(N("$text",1)); if (strlength(L("word")) > 2 && strisalpha(L("word"))) { "words.txt" << L("word") << "\n"; if (!spellword(L("word"))) { AddUniqueCon(G("loo...
@CODE G("enclosed by out") = G("enclosed by"); G("separator out") = G("separator"); G("lineTerminator out") = G("lineTerminator"); G("escaped by out") = G("escaped by"); #======================== Dump Fields ========================= G("field con") = down(G("fields con")); while (G("field con")) { "output.txt" <<...
@NODES _LINE @RULES # for State College, PA _city[layer = (_SchoolRoot)] <- State [s] _xWHITE [s] College [s] @@ _city [layer = (_country)] <- Bermuda [s] @@ _city [layer = (_country)] <- Djibouti [s] @@ _city [layer = (_country)] <- Gibraltar [s] @@ _city [layer = (_country)] <- Grenada [s] @@ _city [layer ...
# Match rank starting with "No." followed by any amount of white space and a number. Reduce to _rank @RULES _rank <- No \. _xWHITE [star] _xNUM  @@
@CODE L("hello") = 0; if (!G("hilite")) # 10/25/10 AM. exitpass(); # 10/25/10 AM. @@CODE #@PATH _ROOT _TEXTZONE _sent _clause @NODES _clause @POST noop(); @RULES _xNIL <- _xWILD [one match=( _noun _verb _adj )] @@
@CODE G("headers") = findconcept(findroot(),"headers"); DisplayKB(G("headers"),0); @@CODE
@CODE G("words") = findconcept(findroot(),"words"); if (!G("words")) G("words") = makeconcept(findroot(),"words"); rmchildren(G("words")); G("alphaNumeric") = makeconcept(G("words"), "AlphaNumeric"); addattr(G("alphaNumeric"), "terms"); G("adjMatrixData") = findconcept(findroot(),"adjMatrixData"); if (!G("adjMatrix...
@NODES _ROOT @POST singlex(4,4); @RULES _text <- \\ [s] ### (1) _xWILD [s one matches=(textit)] ### (2) \{ [s] ### (3) _xWILD [s fail=(\})] ### (4) \} [s] ### (5) @@
@NODES _ROOT @POST excise(1,1); @RULES _xNIL <- _tag ### (1) @@
@NODES _ROOT @POST if (strisupper(N("$text"))) pnrename(N(1),"X"); else pnrename(N(1),"x"); @RULES _xNIL <- _xALPHA @@
@DECL AddWord(L("word"),L("lang"),L("node")) { if (L("lang") != "pt") { return; } L("header") = strtolower(pnvar(L("node"),"header")); L("pos") = PosStr(L("header")); "add.txt" << L("word") << " " << L("pos") << "\n"; if (L("pos")) { L("con") = AddUniqueCon(G("words"),L("word")...
@PATH _ROOT _headerZone _Experience @POST X("companies",3)++; makeconcept(G("company"),N("header")); @RULES _xNIL <- _headerZone ### (1) @@
@NODES _labelEntry @POST AddPhrase(N(2)); "debug.txt" << N("$text", 2) << "\n"; @RULES _xNIL <- _xSTART ### (1) _xWILD [one match=(_xALPHA _xNUM)] ### (2) @@
@CODE closefile(G("dict")); @@CODE
# Count nouns that have a zero feature (i.e., node variable) @PRE <1,1> varz("mass"); @POST ++G("count nonmass nouns"); @RULES _xNIL <- _noun @@
@NODES _ROOT @PRE <1,1> uppercase(); @POST S("header") = N("$text", 1); excise(2,2); single(); @RULES _header <- _xWILD [fails=(\: \n \r)] ### (1) \: ### (2) @@
@NODES _LINE @POST S("etymology") = num(N("$text", 2)); X("header") = "etymology"; single(); @RULES _etymology <- etymology ### (1) _xNUM ### (2) @@
@CODE SaveKB("icd_codes.kbb",G("icd_codes"),2); @@CODE
@NODES _line @POST X("term") = N("$text", 1); X("negation") = N("$text", 5); @RULES _xNIL <- _xWILD [fails=(\t)] ### (1) \t \t \[ _xALPHA @@
@CODE L("hello") = 0; @@CODE @NODES _ROOT @PRE <3,3> varz("NL"); <4,4> var("NL"); # The newline-before-me attribute. @POST if (N("NL",2) > 1) { ++X("PARS"); # Count potential paragraphs. ++S("PAR"); } singler(2,3); @RULES _LINE [unsealed] <- _xANY _xWILD [star fail=(_dummy)] _xANY [opt lookahead] @@
@CODE DisplayKB(findroot(),0); @@CODE
@NODES _ROOT @POST "prose.txt" << N("$text") << "\n\n"; @RULES _xNIL <- _prose ### (1) @@
# Fetch the left or previous sibling of concept. L("return_con") = prev(L("con"));
@CODE fileout("zdump.txt"); @@CODE @NODES _LINE ################ # BLOCK GLOMMING (gulab jamun anyone?) ################ # for things like "roots" or other items that are COMPLETE or # otherwise would rather STAND ALONE! # May want some kind of feature like "noglom" or "complete". # NOTE: PUT NEW ITEMS INTO BOTH RU...
@NODES _ROOT @RULES _looseText <- _xWILD [fails=(_section _break)] @@
# Get levenshtein distance between "hello" and "hell" L("distance") = levenshtein("hello","hell"); # This should evaluate to 1.
@NODES _LINE @POST X("tag") = 1; single(); @RULES _startAttr <- ind attr @@ @POST X("tag") = 1; single(); @RULES _endAttr <- end ind @@