text
stringlengths
22
301k
@NODES _ROOT @POST "funcwords.dict" << N("word") << " pos=" << N("pos") << "\n"; @RULES _xNIL <- _LINE @@
@PATH _ROOT _doctypedecl _AttlistDecl @RULES _DefaultDecl <- \# [one] ### (1) _xWILD [s one matches=("REQUIRED" "IMPLIED")] ### (2) @@ _DefaultDecl <- \# [one] ### (1) _xWILD [s min=1 max=1 matches=("FIXED")] ### (2) _whiteSpace [opt] ### (3) _PEReference [one] ### (4) @@ _Default...
@PATH _ROOT _zoneHeader @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
# Fetch attribute's list of values. L("return_val") = attrvals(L("attr"));
@NODES _ROOT @CHECK if () @RULES _xNIL <- _xWILD [min=3 matches=(_)] ### (1) @@
@CODE # rmchildren(findroot()); L("codes") = findconcept(findroot(), "icd_codes"); L("cod") = findconcept(L("codes"), "code2words"); L("proc") = findconcept(L("cod"), "procedures"); DisplayKB(L("proc"), 1); L("iter") = G("level_1_con"); while(L("iter")) { "testing_nav.txt" << conceptname(L("iter")) << "\n"; ...
tokenize nil # Gen: Convert input to token list. pat kb # comment pat tags # comment pat items # comment pat count # comment pat names # comment pat output # comment
@CODE L("filename") = G("$kbpath") + "\\en.dict"; if (G("$isfirstfile")) { G("dict") = openfile(L("filename")); } else { G("dict") = openfile(L("filename"),"app"); } @@CODE
@NODES _LINE @POST if (X("num")) { N("num",1) = X("items")++; if (N("$text",1) != ",") { if (!N("str")) { N("value") = N("$text",1); } N("header") = NthHeader(N("num")); if (N("header") == "ClassKind") X("ClassKind") = N("$text",1); } } @RULES _xNIL <- _item ### (1) @@
# To demonstrate nextattr, we first need to build a KB: @CODE # if you find apples in the concept hierarchy if (findconcept(findroot(),"apple")) # kill them (to start fresh) rmconcept(findconcept(findroot(),"apple")); # Create the apple concept G("apple") = makeconcept(findroot(),"apple"); # Apples have color addstr...
# Compute base 10 logarithm of 3.1 and print to "output.txt" @CODE "output.txt" << logten(3.1) << "\n"; @@CODE Outputs something like: .49136
@NODES _ROOT @RULES _interjection <- hello ### (1) @@
# In CHECK Region and CODE Region, succeed without executing further code @CHECK succeed(); @@CHECK
# See if the given analyzer is loaded into memory @CODE L("ana present") = findana("TAIParse");
@NODES _ROOT @PRE <2,2> varz("NL"); @RULES _LINE <- _xSTART ### (1) _xWILD [plus] ### (2) @@ @PRE <1,1> var("NL"); <2,2> varz("NL"); @RULES _LINE <- _xWILD [one] ### (1) _xWILD [star] ### (2) @@
@NODES _LINE @RULES _skill <- _xWILD [s one matches=( assembly basic cgi dec dos eurolang excel fortran galaxy graphic graphics html interface interfaces internet java javascript lisp mac macintosh motif netscape next pascal pc perl prolog smalltalk sql sun sunview trados unix vax webmaster windowing word workstati...
@NODES _textZone @RULES _BLANKLINE <- _xWILD [min=0 max=0 matches=(\ \t \r)] ### (1) \n ### (2) @@ _LINE <- _xWILD [min=0 max=0 fails=(\r \n)] ### (1) _xWILD [one match=(\n _xEND)] ### (2) @@
@CODE G("labels") = findconcept(findroot(),"labels"); if (!G("labels")) G("labels") = makeconcept(findroot(),"labels"); rmchildren(G("labels")); @@CODE
@CODE prlit("output.xml","</History>\n"); @@CODE @RULES _xNIL <- _xNIL @@
@NODES _ROOT @RULES _equation <- _beginEq [s] ### (1) _xWILD [s] ### (2) _endEq [s] ### (3) @@ @POST S("equation") = N("$text",2); single(); @RULES _equationInline <- \$ [s] ### (1) _xWILD [s] ### (2) \$ [s] ### (3) @@
@CODE L("hello") = 0; @@CODE @NODES _TEXTZONE # noncount or mass nouns. Need to build a full listing. @POST N("mass") = 1; @RULES _xNIL <- _xWILD [s one match=( advice AIDS air aluminum anger applause attire bacon beauty beef beer behavior biology blood boating bread broccoli butter cabbage cake camping cancer c...
@CODE G("dict") = findconcept(findroot(),"dict"); if (!G("dict")) G("dict") = makeconcept(findroot(),"dict"); rmchildren(G("dict")); @@CODE
@CODE L("hello") = 0; if (!G("hilite")) # 10/25/10 AM. exitpass(); # 10/25/10 AM. @@CODE @PATH _ROOT _TEXTZONE @POST noop(); @RULES _xNIL <- _xALPHA [plus] @@
# Reduce "fly" to a verb and then a vg (or "verb @POST   noop(); @RULES _xNIL <-  to fly [layer=(_verb _vg)] @@
@NODES _LINE @PRE <1,1> cap(); @RULES # Ex: Motif _ProgrammingLanguage <- _xWILD [min=1 max=1 s match=("Motif" "Pascal")] @@
@DECL # Join KB path concept names to form Radlex phrase GetKBPathString(L("path")) { L("pathArray") = split(L("path"), " "); L("len") = arraylength(L("pathArray")); L("i") = 3; L("string") = L("pathArray")[2]; L("string") = strpiece(L("string"), 1, strlength(L("string"))-2); while (L("i") < L("len")) { L(...
@NODES _ROOT @POST "indexList.txt" << N("words", 1) << "\n"; noop(); @RULES _xNIL <- _labelEntry @@
@CODE G("vocab") << "\n"; closefile(G("debug")); closefile(G("vocab")); @@CODE
@PATH _ROOT _LINE _Caps # But how to subtype headers!? # Probably best is: decide you have a header first, then # count up the subtype confidences... @POST ++X("headerroots"); if (N("$end")) ++X("end headerroot"); @RULES _xNIL <- _headerWord [s] @@ _xNIL <- _header [s] @@ # Just in case this is allowed. @P...
# Extract a normalized directory path from a URL @CODE "output.txt" << urlbase("http://www.x.com/pqr/a.txt") << "\n"; "output.txt" << urlbase("http://www.abc.com/") << "\n"; "output.txt" << urlbase("http://www.x.com/pqr/") << "\n"; prints out: http://www.x.com/pqr http://www.abc.com http://www.x.com/pqr
@NODES _LINE @RULES _comma <- \, ### (1) @@
@PATH _ROOT _doctypedecl _AttlistDecl @RULES _DefaultDecl <- \# [one] ### (1) _xWILD [s one matches=("REQUIRED" "IMPLIED")] ### (2) @@ _DefaultDecl <- \# [one] ### (1) _xWILD [s min=1 max=1 matches=("FIXED")] ### (2) _whiteSpace [opt] ### (3) _PEReference [one] ### (4) @@ _Default...
@NODES _ROOT @RULES _zap <- _xWILD [plus fail=(_word _textZone)] ### (1) @@
@NODES _ROOT @POST G("verb") = N("$text",5); "debug.txt" << "verb: " << G("verb") << "\n"; singler(5,5); @RULES _verb <- \< ### (1) title ### (2) \> ### (3) Conjugation ### (4) _xALPHA ### (5) @@
@CODE G("output") = G("$inputhead") + ".kbb"; G("kb") = makeconcept(findroot(),"kb"); @@CODE
@PATH _ROOT _LINE _Caps @POST ++X("humannames"); if (N("$end")) ++X("end humanname"); if (N("$start")) ++X("start humanname"); @RULES _xNIL <- _humanNamepart [s] @@
@NODES _LINE @POST X("words") = X("words") + 1; if (strlength(N("$text")) > 1) { if (striscaps(N("$text")) && strlength(N("$text")) > 1) { X("caps") = X("caps") + 1; } else if (strisupper(N("$text")) && strlength(N("$text")) > 1) { X("upper") = X("upper") + 1; } } if (N("common") || (N("lower") &&...
@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 [...
@NODES _ROOT @POST makeconcept(G("kb"),N("$text",1)) @RULES _xNIL <- _xALPHA ### (1) @@
# Fetch concept given its string path if (findconcept(findroot(),"parent")) rmconcept(findconcept(findroot(),"parent")); G("childConcept") = makeconcept(makeconcept(findroot(),"parent"),"child"); G("the path") = conceptpath(G("childConcept")); "output.txt" << "The path is: " << G("the path") << "\n"; G("the concept"...
@NODES _LINE @POST X("rank") = num(N("$text")); @RULES _xNIL <- _rank ### (1) @@ @POST X("country") = N("$text"); @RULES _xNIL <- _country ### (1) @@ @POST X("pop") = num(strsubst(N("$text"),",",0)); @RULES _xNIL <- _pop ### (1) @@
@NODES _ROOT @POST if (num(N("words")) && num(N("words")) == num(N("caps"))) { N("level") = 1; single(); } else if (num(N("words")) && num(N("words")) == num(N("upper")) && N("words") <= 3) { N("level") = 2; single(); } @RULES _header <- _LINE ### (1) @@
@CODE G("numbers") = getconcept(findroot(),"numbers"); rmchildren(G("numbers")); @@CODE
@NODES _LINE @PRE <1,1> cap(); @RULES # Ex: International _companyModroot <- _xWILD [min=1 max=1 s match=("International" "Associates" "Bookstore" "Brands" "Casinos" "Centers" "Chemical" "Communications" "Companies" "Consulting" "Devices" "Dynamics" "Electric" "Electronic" "Electronics" "Energy" "Engineering" "Enter...
@NODES _ROOT @POST L("word") = strtolower(N("$text",1)); L("word con") = findconcept(G("words"),L("word")); "debug.txt" << "word: " << L("word") << "\n"; if (L("word con")) { "debug.txt" << "Found word: " << L("word") << "\n"; L("code") = down(L("word con")); while (L("code")) { L("con") = AddUniqueCon(G("match...
@NODES _bodyZone @RULES _trZone <- _tr ### (1) _xWILD [fail=(_trClose)] ### (2) _trClose ### (3) @@
@PATH _ROOT _contactZone _LINE _Caps # 12/25/99 AM. # Hand building generalized human name. # @PRE <1,1> cap(); <1,1> length(1); <4,4> cap(); <4,4> length(1); <7,7> cap(); @CHECK if (!X("humanNameCandidate",3)) fail(); # Line is likely candidate. @POST # Rename the cap phrase node. xrename("_humanName"); # noo...
@MULTI _ROOT @POST S("num") = N("num", 1); excise(1,1); single(); @RULES _item <- _listItem _xWILD [fails=(_listItem _xEND)] @@
# Match a _verb node optionally preceded by _modal, _have, or _be nodes, reducing to _vgroup @RULES _vgroup <- _modal [optional] _have [optional] _be [optional] _verb @@
# Traverse caps in experience instance, assigning conf. as # job title, company name. # Compute a score for each capitalized phrase based on its # absolute confidence plus factor based on distance from anchor. # Retain the maximum with the experience instance. @PATH _ROOT _experienceZone _experienceInstance _LINE @P...
@PATH _ROOT _LINE _countryText @POST L("text") = strtolower(N("$text",2)); if (L("text") != "the") { X("full",2) = L("text"); } single(); @RULES _parens <- \( ### (1) _xWILD [fail=(\))] ### (2) \) ### (3) @@
@CODE L("con") = getconcept(findroot(), "kb"); # L("con_3") = makeconcept(L("con"), "con_3"); # L("def_con_3") = makeconcept(L("con_3"), "def_con_3"); # addstrval(L("def_con_3"), "keyword1", "a system test"); # addstrval(L("def_con_3"), "keyword2", "system"); # addstrval(L("def_con_3"), "keyword3", "system test"); Di...
@DECL AddOrder(L("node"),L("sent")) { L("name") = pnname(L("node")); L("text") = pnvar(L("node"),"$text"); L("conname") = strpiece(L("name"),1,strlength(L("name"))-1); L("con") = makeconcept(L("sent"),L("conname")); return L("con"); } GetAbbreviation(L("word")) { "abbrev.txt" << L("word"); ...
@PATH _ROOT _section @POST L("icdDiagnoses") = GetICDTerms(N(2), "diagnoses"); L("icdProcedures") = GetICDTerms(N(2), "procedures"); if(L("icdDiagnoses")) { L("count") = 0; while (L("count") < arraylength(L("icdDiagnoses"))) { "icdDiagnoses.txt" << "\t" << L("icdDiagnoses")[L("count")] << "\n"; L("count") = L(...
@CODE # Change the passed argument to the concept you are wanting to Dump DisplayKB(G("radlex"),1); @@CODE
@PATH _ROOT _paragraph _sentence @PRE <3,3> varz("name"); @POST S("title") = N("$text",1); if (N(3)) S("agency") = N("$text",3); group(2,3,"_agency"); single(); @RULES _title <- _title ### (1) for ### (2) _xCAP [plus] ### (3) @@
################################################# # FILE: HTML Text Functions.pat # # SUBJ: Distinguish between formatting elements # # in HTML tags and other tags # # AUTH: Paul Deane # # CREATED: 07/Jun/01 # DATE OF THIS VERSION: 31/Aug/01 ...
# Find dictionary concept wordString in the dictionary hierarchy of KB, return handle to concept @CODE "output.txt" << "1 " << conceptname(addword("hello")) << "\n"; "output.txt" << "2 " << conceptname(wordindex("hello")) << "\n"; "output.txt" << "3 " << findwordpath("hello") << "\n"; "output.txt" << "4 " << findword...
@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 prlit("ctc.txt", "\n Contact Zone Cap Phrases\n"); prlit("ctc.txt", "----------------------------------\n"); @@CODE @PATH _ROOT _contactZone _LINE @POST ndump("ctc.txt",1); prlit("ctc.txt", "-------\n"); @RULES _xNIL <- _Caps @@ _xNIL <- _humanName @@
@CODE # L("word") = down(G("pos")); # while (L("word")) { # L("pos") = down(L("word")); # L("w") = conceptname(L("word")); # while (L("pos")) { # "pos.dict" << L("w") << " pos=" << conceptname(L("pos")) << "\n"; # L("pos") = next(L("pos")); # } # L("word") = next(L("word")); # } #...
# Match one node of inc, ltd, company, or firm, and reduce to _company _company <- _xWILD [s one matches=(inc ltd company firm)]
@CODE SaveKB("everything.kbb",findroot(),2); @@CODE
@CODE sortchilds(G("langs")); L("file2") = "iso-languages2.dict"; L("file3") = "iso-languages3.dict"; L("lang") = down(G("langs")); while (L("lang")) { L("attrs") = DictDisplayAttr(L("lang"),"language"); L("file2") << conceptname(L("lang")) << " iso=2 " << L("attrs") << "\n"; L("file3") << strval(L("lang"),"iso2"...
@NODES _ROOT @RULES
@NODES _NLPPP @POST movesem(2) single() @RULES _IFPART <- _IF _xWILD [s one match=( _EXPR _NUM _FLOAT _STR )] @@ # Simple statements. @POST # movesem(1) # makestmt(1) # 05/11/00 AM. single() @RULES # NOTE: num and str aren't handled as statements, for now. _STMT <- _xWILD [s one match=( _EXPR _NUM _FLOAT _S...
@DECL # Takes PN node and add subsequent tokens to # KB ti form a hierarchy AddPhrase(L("node")) { L("con") = G("phrases"); while (L("node")) { L("text") = pnvar(L("node"), "$text"); L("con") = AddUniqueCon(L("con"), L("text")); L("node") = pnnext(L("node")); if (!L("node")) { makeconcept(L("con"), "000...
# Fetch name of given concept. L("return_str") = conceptname(L("con"));
# Replace the hyphenated "moti-vate" with "motivate" @POST  singlezap(); @RULES motivate <- moti \- vate @@
@NODES _LINE @PRE <1,1> length(3); @RULES # Ex: and _posCONJ [layer=(_funWORD )] <- _xWILD [min=1 max=1 s match=("and")] @@
@CODE L("hello") = 0; @@CODE @NODES _TEXTZONE # New tokenization handlers. @CHECK if (!N("dissolve")) fail(); @POST splice(1,1); @RULES _xNIL <- _tok @@
@PATH _ROOT _contactZone _LINE _Caps @CHECK if ( !X("name found",2) && !G("humannames") # No hi conf names found yet. && X("humanname conf") >= 50 # Caps is reasonable to try. ) succeed(); fail(); @POST # If fit this pattern, raise confidence a bunch. X("humanname conf") = X("humanname conf") %% 80...
# Sort concept's subhierarchy in alphabetic order L("con") = getconcept(findroot(),"top"); getconcept(L("con"),"32"); getconcept(L("con"),"3"); getconcept(L("con"),"33"); # Another layer. getconcept(L("33"),"c"); getconcept(L("33"),"b"); getconcept(L("33"),"a"); sortchilds(L("con")); sorthier(L("con")); Before sorting...
# Sort concept's phrase nodes alphabetically. sortphrase(L("con"));
@NODES _LINE @RULES # Ex: "(The) (XXX) U niversity of XXX (XXX)," _SchoolName [] <- _xWILD [opt s match=(The)] _xWHITE [star s] # _xALPHA [opt s fails=( University _xWHITE The)] # _xWHITE [star s] _xALPHA [opt s fails=( University _xWHITE The)] _xWHITE [star s] _xWILD [min=1 max=1 s match=(University) ...
@NODES _ROOT @PRE <1,1> var("up"); @POST splice(1,1); @RULES _xNIL <- _LINE ### (1) @@
@PATH _ROOT _experienceZone _experienceInstance _LINE _experiencePart _Caps @POST X("job title",3) = N("$text"); @RULES _xNIL <- _jobTitle [s] @@ _xNIL <- _jobPhrase [s] @@ _xNIL <- _jobTitleRoot [s] @@
@PATH _ROOT _doctypedecl _EntityDecl @POST if (N("$text",4)) S("buffer1") = str(N("$text",4)) ; if (N("$text",5)) S("buffer2") = str(N("$text",5)) ; if (S("buffer1") && S("buffer2")) { S("EntityName") = S("buffer1") + S("buffer2") ; } else if (S("buffer1")) S("EntityName") = S("buffer1") ; else if (S("...
@NODES _ROOT @POST oldsplice(1,1) # 07/19/02 AM. @RULES _xNIL <- _NLPPP @@
# Copy a node's variables to the suggested node of a rule match @POST pncopyvars(N(2)); # Copy head _noun variables to _np node. single(); @RULES _np <- _det [s] _noun [s] @@
@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 prlit("output.xml", "</CandidateProfile>\n"); prlit("output.xml", "</Body>\n"); prlit("output.xml", "</BizTalk>\n"); @@CODE @RULES _xNIL <- _xNIL @@
@CODE L("hello") = 0; @@CODE #@PATH _ROOT _TEXTZONE _sent _clause @NODES _clause # Looking for suitable by-actor adverbial. # For passive, will support transformation to active. @POST if (N("by-actor") && !X("by-actor")) X("by-actor") = N("by-actor"); if (N("subs")) X("last np") = N("subs")[0]; noop(); @R...
@CODE L("hello") = 0; @@CODE @NODES _TEXTZONE @POST ++S("don't splice"); single(); @RULES _date [layer=(_noun _np)] <- _xNUM _xWILD [star match=(_xWHITE _nbsp)] _xWILD [one match=(GMT PST MST CST EST)] @@ @POST ++S("don't splice"); S("temporal") = 1; S("dy") = num(N("$text",3)); S("mo") = num(N("$t...
@CODE L("hello") = 0; @@CODE @NODES _sent # vg np conj vg @POST # Align verb assignments. L("pos") = vgpos(N(1)); L("voice") = N("voice",1); fixvg(N(4),L("voice"),L("pos")); @RULES _xNIL <- _vg _np [opt] _conj _vg @@ # vg np prep np vg # threw people in a mine filled .... @POST fixvg(N(5),"passive","V...
@NODES _LINE @PRE <1,1> cap(); @RULES # Ex: Projects _ExperienceHeaderWord [layer=(_headerWord )] <- _xWILD [min=1 max=1 s match=("Projects" "Employment" "Experience")] @@
@NODES _ROOT @POST excise(1,1); noop(); @RULES _xNIL <- _xBLANK [s] ### (1) @@
@NODES _LINE @RULES # Ex: A.\_A. _degreePhrase [layer=(_Caps )] <- _degree [s] @@ @PRE <1,1> cap() @RULES # Ex: AS _degreePhrase [layer=(_Caps )] <- AS [s] @@ # Ex: BA _degreePhrase [layer=(_Caps )] <- BA [s] @@ # Ex: BS _degreePhrase [layer=(_Caps )] <- BS [s] @@ # Ex: BSc _degreePhrase [layer=(_Caps )] <- BSc ...
############################################### # FILE: cleanNotes # SUBJ: comment # AUTH: Ashton # MODIFIED: ############################################### @NODES _ROOT @POST setunsealed(1, "true"); noop(); @RULES _xNIL <- _xWILD [one matches=(_patientID _time _init)] @@
@CODE L("hello") = 0; @@CODE
@CODE G("Delimiter") = "\t"; @@CODE
@NODES _LINE @POST group(2,2,"_item"); @RULES _xNIL <- _xSTART ### (1) _comma ### (2) @@ @POST group(2,2,"_item"); @RULES _xNIL <- _comma ### (1) _comma ### (2) @@
# Sort concept's immediate children in alphabetic order L("con") = getconcept(findroot(),"top"); getconcept(L("con"),"32"); getconcept(L("con"),"3"); getconcept(L("con"),"33"); sortchilds(L("con")); Before sorting, the children of "top" are ordered 32, 3, 33. After sorting, the order is changed to 3, 32, 33.
@NODES _LINE @PRE <1,1> cap(); @RULES # Ex: MIT _schoolPhrase [layer=(_Caps )] <- MIT [s] @@ # Ex: SJSU _schoolPhrase [layer=(_Caps )] <- SJSU [s] @@ # Ex: UCLA _schoolPhrase [layer=(_Caps )] <- UCLA [s] @@ # Ex: UCSB _schoolPhrase [layer=(_Caps )] <- UCSB [s] @@ # Ex: UCSD _schoolPhrase [layer=(_Caps )] <- UCSD ...
@CODE G("dict") = findhierconcept("dict",findroot()); G("alphas") = findhierconcept("a",G("dict")); G("letter") = down(G("alphas")); G("nouns") = 0; G("adjectives") = 0; G("adverbs") = 0; G("unmarked") = 0; G("knowns") = 0; while (G("letter")) { G("subletter") = down(G("letter")); while (G("subletter")) { G("...
# Fetch attribute's name. L("return_str") = attrname(L("attr"));
@PATH _ROOT _LINE _Caps @POST ++X("companyroots"); if (N("$end")) ++X("end companyroot"); @RULES _xNIL <- _companyRoot [s] @@ @POST ++X("companymodroots"); if (N("$end")) ++X("end companymodroot"); @RULES _xNIL <- _companyModroot [s] @@ @POST ++X("companymods"); @RULES _xNIL <- _companyMod [s] @@...
@PATH _ROOT _headerZone @POST S("title") = N("title",1); single(); @RULES _conjugationGroup <- _paraGroup ### (1) _xWILD [plus fail=(_paraGroup)] ### (2) @@
# "rough out" a set of nodes ending in a period, @NODES _np @POST  ++X("nouns"); @RULES _xNIL <- _noun @@
@POST rfaregion(1, 2, 3, 4) single() @RULES # Opt: try triggering the last elt. _REGION [base] <- _PRES [opt] _CHECKS [opt] _POSTS [opt] _RULES @@