text
stringlengths
22
301k
@CODE DisplayKB(G("icd_hier"),1); SaveKB("icd_hierarchy.kbb",G("icd_hier"),2); @@CODE
@NODES _ROOT @RULES _item <- _itemOpen ### (1) _xWILD [fails=(_itemClose)] ### (2) _itemClose ### (3) @@
@NODES _LINE @PRE <1,1> cap(); <3,3> cap(); <5,5> cap(); @RULES # Ex: American\_Sign\_Language _naturalLanguages [layer=(_Caps )] <- American [s] _xWHITE [star s] Sign [s] _xWHITE [star s] Language [s] @@ @PRE <1,1> cap(); @RULES # Ex: ASL _naturalLanguages [layer=(_Caps )] <- ASL [s] @@ # Ex: Afrikaans _naturalLa...
@CODE fileout("dump.txt"); prlit("dump.txt","\n"); prlit("dump.txt","ALP NUM PUN WHT BLOBS INDENT WALP WCAP WALL\n"); prlit("dump.txt","-------------------------------------------\n"); @@CODE @NODES _ROOT # Print out the total count of vars in each line. @POST "dump.txt" << rightjustifynum(N("nalpha",1), 3) << " ";...
@PATH _ROOT _textZone _LINE @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@ @POST X("up",3) = 1; "found.txt" << "this\n"; @RULES _xNIL <- _language [s] ### (1) @@
@NODES _FOOTER @POST "zap.txt" << N("$text") << " - 2\n"; excise(1,1); @RULES _xNIL <- _xWILD [one match=(_beginEnum _endEnum _itemMarker _COMMENT _spacing)] ### (1) @@
@CODE L("hello") = 0; @@CODE #@PATH _ROOT _TEXTZONE _sent _seg @NODES _seg # Assume we're here because this is an np. @CHECK if (!N(2) && !N(3) && !N(4)) fail(); # Handle the raw alpha alpha elsewhere. if (!N("noun",6)) # 01/12/05 AM. fail(); @POST if (N("verb",6)) X("last verb") = 1; # Last is poss...
@NODES _ROOT @POST if (N("code", 1)) { GetWordCodeMappings(N(1)); } @RULES _xNIL <- _term ### (2) @@
@PATH _ROOT @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@NODES _ROOT @POST S("language") = N("$text",2); "lang.txt" << N("$text",2) << "\n"; single(); @RULES _language <- _langStart ### (1) _xWILD [plus fails=(_langEnd)] ### (2) _langEnd ### (3) @@ @RULES _conjugation <- _startConju ### (1) _xWILD [plus fails=(\})] ### (2) \} ### (3) \} ...
@CODE if (G("pretagged")) exitpass(); @@CODE @NODES _TEXTZONE @POST S("neg") = 1; S("mypos") = "VBP"; single(); @RULES _modal <- won \' t @@ _modal <- can \' t @@ _modal <- cannot @@ _modal <- mayn \' t @@ _modal <- mightn \' t @@ _modal <- shan \' t @@ _modal <- oughtn \' t @@ _modal <- mustn \' t @@ _moda...
# Fetch the first word-concept in the KB dictionary hierarchy. L("return_con") = dictfirst(L(""));
# show how we can create a concept like noun and assign it as the value of a word's attribute. We 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(),"nou...
@PATH _ROOT _pronunciations _headerZone _LINE @POST addstrval(X("pronunciation",2),"phonetic",N("$text",1)); "debug.txt" << N("$text",1) << "\n"; @RULES _xNIL <- _phonetic ### (1) @@
############################################### # FILE: XML OverallSchema.pat # # SUBJ: Put together the last pieces of an XML# # document # # AUTH: Paul Deane # # CREATED: 14/Jan/01 # DATE OF THIS VERSION: 31/Aug/01 # ...
@CODE DisplayKB(G("icd_codes"),1); SaveToKB(G("icd_codes"), "icd_mapping.kbb"); @@CODE
@PATH _ROOT _headerZone _Experience _headerZone _LINE @RULES _dateRange <- _xNUM ### (1) to ### (2) _xWILD [match=(_xNUM present)] ### (3) @@
@CODE L("hello") = 0; @@CODE @NODES _sent # np lists... @POST if (pnname(N(7)) != "_np") { nountonp(7,1); } group(2,7,"_np"); N("list-np",2) = 1; # listadd(7,2,"true"); @RULES _xNIL <- \, _xWILD [one match=(_noun _np)] \, _xWILD [one match=(_noun _np)] \, [opt] _conj _xWILD [one match=(_noun _np)...
@NODES _LINE @RULES # Taking out the big list of cities. # _CityName <- _xWILD [s one match=( _cityPhrase _cityWord)] @@
@PATH _ROOT _paragraph _sentence @POST S("comment") = makeconcept(N("object",1),"comment"); addstrval(S("comment"),"position",N("$text",9)); addstrval(S("comment"),"commentor",N("$text",10)); single(); @RULES _event <- _eventAnaphora [s] ### (1) _prep [s] ### (2) _det [s] ### (3) ...
@PATH _ROOT _LINE # Should be a header from caps, not one from kb. Need to flag. @POST N("hi hdr conf") = 0; N("hi hdr class") = "NULL"; if (N("end education hdr")) N("hi hdr class") = "edu"; else if (N("end skills hdr")) N("hi hdr class") = "skills"; else if (N("end experience hdr")) N("hi hdr class") ...
@NODES _LINE @PRE <1,1> cap(); <1,1> length(9); @RULES # Ex: Objective _ObjectiveHeaderWord [layer=(_headerWord )] <- _xWILD [min=1 max=1 s match=("Objective")] @@
# Compute a stem for nouns and verbs @CODE G("stem") = stem("lounging"); @@CODE
@PATH _ROOT _paragraph _sentence ############################################### # Ronald DiPietro (a Certified Public Accountant) ############################################### @POST S("con") = AddPerson(N(1),0); AddUniqueStr(S("con"),"title",N("title",2)); single(); @RULES _person <- _person ### (1) _titlePare...
@NODES _ROOT @RULES _choiceElement [unsealed] <- _whiteSpace [opt] ### (1) \| ### (2) _whiteSpace [opt] ### (3) _cp ### (4) _xWILD [opt matches=("*" "+" "?")] ### (5) @@ _seqElement [unsealed] <- _whiteSpace [opt] ### (1) \, [one] ### (2) _whiteSpace [opt] ### (3) _cp [one] ###...
# Convert a relative URL to an absolute URL @CODE "output.txt" << resolveurl("http://www.abcd.edu/x/y/z.html", "../gif/img1.gif")     << "\n"; prints out: http://www.abcd.edu/x/gif/img1.gif
@CODE L("hello") = 0; @@CODE @NODES _TEXTZONE @POST excise(1,1); @RULES _xNIL <- _xWHITE [plus] @@
@NODES _LINE @PRE <2,2> length(1); @POST L("text") = N("$text"); if (L("text") != "(") { L("bullet") = getconcept(G("format"),"bullet"); L("con") = AddUniqueCon(L("bullet"),L("text")); X("bullet") = 1; IncrementCount(L("con"),"count"); single(); } @RULES _bullet <- _xSTART ### (1) _xWILD [o...
@PATH _ROOT _doctypedecl @POST G("CurrentElementName") = str(N("ElementName",1)) ; noop() ; @@POST @RULES _xNIL <- _ElementDeclStart [one] ### (1) @@ @@RULES @POST G("CurrentElementName") = 0 ; noop() ; @@POST @RULES _xNIL <- _EndTag [one] ### (1) @@ @@RULES @RULES _Mixed <- _PCDataStart ...
@CODE DispKB(); @@CODE
@NODES _split @POST "test.log" << X("split") << ": " << N("$text", 1) << "\n"; L("code") = N("$text", 1); L("alt_code_format1") = "0"+N("$text", 1); L("alt_code_format2") = "00"+N("$text", 1); L("code_con") = findconcept(G("icd9_codes"), N("$text", 1)); L("alt_code_con1") = findconcept(G("icd9_codes"), L("alt_code_fo...
# Find first named node in phrase. L("return_con") = findnode(L("phrase"), L("name"));
@NODES _LINE @RULES _year <- _xWILD [one s match=( 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2...
# Convert the strings in multi-string valued global variable to lower case @CODE G("strs") = "abc"; G("strs")[1] = "def"; gtolower("strs"); "output.txt" << G("strs") << "\n";
@NODES _split @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 closefile(G("file")); @@CODE
@CODE ### ICD Keywords ############################################## G("words") = findconcept(findroot(),"words"); if (!G("words")) G("words") = makeconcept(findroot(),"words"); rmchildren(G("words")); G("procedure_words") = AddUniqueCon(G("words"), "procedure"); rmchildren(G("procedure_words")); G("diagnosis_word...
@PATH _ROOT _Mixed @RULES _childItem <- _whiteSpace [opt] ### (1) \| [one] ### (2) _whiteSpace [opt] ### (3) _xWILD [s one matches=("_xALPHA" "_" ":")] ### (4) _xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (5) @@ _childItem <- _whiteSpace [opt] ### (1) \| [one] ### (...
# TODO: PUT YOUR CONTEXT IN HERE. @NODES _TEXTZONE # TODO: SET UP USER ACTIONS HERE. @POST pncopyvars(1); # 06/05/06 AM. S("ne text") = phrasetext(); S("ne type") = "location"; S("ne type conf") = 95; S("ne") = 1; S("sem") = "location"; S("sem location") = "country"; S("mypos") = "NP"; S("country") ...
@PATH _ROOT _header @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@CODE L("hello") = 0; @@CODE #@PATH _ROOT _TEXTZONE _sent @NODES _sent # det alpha # NIBBLE. @CHECK if (N("unknown",3)) succeed(); if (N("number",1) == "singular" && plural(N(3))) fail(); if (!N("verb",3)) fail(); if (N("pos num",3) < 2) fail(); @POST N("pos25 det-a-a") = 1; if (N("unknown",...
@NODES _ROOT @RULES _subgroup <- _subgroupHeader ### (1) _xWILD [fail=(_subgroupHeader _groupHeader)] ### (2) @@
@NODES _LINE @POST noop(); @RULES _xNIL <- _xWILD [fail=(\t) group="_column"] ### (1) \t ### (2) _xWILD [fail=(\t) group="_column"] ### (3) \t ### (4) _xWILD [fail=(\t) group="_column"] ### (5) \t ### (6) _xWILD [fail=(\t) group="_column"] ### (7) \t ### (8) _xWILD [fa...
# Remove node from concept's phrase. rmnode(L("con"));
@CODE GetTitles(G("top")); GetTitles(G("rare")); DisplayKB(G("mimic_splits"), 1); SaveToKB(G("mimic_splits"),"mimic_splits"); @@CODE
@NODES _enum @RULES _itemMarker <- \\ [s] ### (1) item [s] ### (2) @@
# See if analyzer is operating in an interactive environment @CODE # In VisualText, send output to a file, but outside of VisualText, direct outputs to a user-supplied buffer. if (interactive())    G("out") = "buf.txt"; else    G("out") = cbuf(); G("out") << "Hello output!" << "\n"; @@CODE
@NODES _ROOT @POST if (num(N("words")) && num(N("words")) == num(N("caps"))) { N("level") = 1; N("possible") = 1; single(); } # else if (num(N("words")) && num(N("words")) == num(N("upper")) && N("words") == 1) { # N("level") = 2; # single(); # } @RULES _header <- _LINE ### (1) @@
# Fetch entire path of given concept as a string. L("return_str") = conceptpath(L("con"));
# Remove dictionary concept from KB. rmword(L("str"));
@PATH _ROOT _bodyZone _trZone _tdZone @POST X("value") = N("$text",3); @RULES _xNIL <- _td ### (1) _strong [opt] ### (2) _xWILD [fail=(_tdClose _strongClose)] ### (3) _strongClose [opt] ### (4) _tdClose ### (5) @@
@NODES _LINE @RULES _GPA <- Grade [s] _xWHITE [s star] Point [s] _xWHITE [s star] Average[s] @@ _GPA <- GPA [s] @@ _GPA <- G [s] \. [s opt] _xWHITE [s star] P [s] \. [s opt] _xWHITE [s star] A [s] @@ # Changing this to exploit NLP++. # @POST if ((num(N("integer")) >= 2 || num(N("integer")) <=...
@PATH _ROOT _LINE _brackets @PRE <3,3> lowercase(); @POST if (!X("word",2)) { X("word",2) = N("$text",3); "words.txt" << N("$text",3) << "\n"; } @RULES _xNIL <- _xSTART ### (1) \[ ### (2) _xWILD [plus match=(_xALPHA \_ \-)] ### (3) @@
@NODES _ROOT @RULES _xNIL <- _xNIL ### (1) @@
@NODES _ROOT @POST S("label") = makeconcept(G("labels"), N("$text", 1)); single(); @RULES _labelEntry <- _xWILD [fails=(\n \r)] ### (1) _xWILD [one match=(\n \r _xEND)] ### (2) @@
@NODES _LINE @POST setbase(1,"false"); @RULES _xNIL <- _Caps @@
@NODES _ROOT @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE ### (1) @@
# Fetch the concept that node is a proxy for. L("return_con") = nodeconcept(L("node"));
@CODE DisplayKB(G("root"), 0); @@CODE
@PATH _ROOT _headerZone _iOpen @POST X("attr") = N("$text",1); X("value") = N("$text",4); @RULES _xNIL <- _xALPHA ### (1) \= ### (2) \" ### (3) _xWILD [fail=(\")] ### (4) \" ### (5) @@
@DECL ######## # FUNC: REGISTERX # SUBJ: Add string to a node's variable. # EX: register(X(4),"temporal"," # Adds a date string to "temporal" var of node # in context. # NOTE: For adding multiple values to a variable. # Should rename this to something else. # Lowercase register() conflicts with C++ reserved word, # wh...
@MULTI _ROOT _LINE _split @POST excise(1,1); @RULES _xNIL <- _xWILD [one matches=(\n \r _BLANKLINE)] ### (1) @@
@NODES _LINE @RULES # Ex: interdisciplinary _fieldNames <- _xWILD [min=1 max=1 s match=(interdisciplinary accounting acoustics adapted administration adult advertising aeronautical aeronautics aerospace aesthetics affairs african africology afro agribusiness agricultural agronomy air american analysis anatomy animal ...
# Perform a reduction on the range of rule elements from node1 to node2 and name the group node labelString. node1 and node2 should be a well-formed range in the current rule match.  For example from N(1) to N(3) @POST L("n") = group(N(1),N(2),"_np"); "output.txt" << pnname(L("n")) << "\n"; @RULES _xNIL <- _det _noun ...
@NODES _LINE @POST ResolvePronoun(X("con"),N("con")); @RULES _xNIL <- _pro ### (1) @@
@NODES _ROOT @CODE G("people") = 0; @@CODE
@NODES _ROOT @POST S("code") = N("$text", 1); S("term") = N("$text", 3); excise(4,4); excise(1,2); single(); @RULES _entry<- _xWILD [fails=(\t _icdRoot)] ### (1) \t ### (2) _xWILD [fails=(\n \r)] ### (3) _xWILD [one matches=(\n \r)] ### (4) @@
@NODES _ROOT @RULES _trStart <- \< tr \> @@ _trEnd <- \< \/ tr \> @@ _tdStart <- \< td \> @@ _tdEnd <- \< \/ td \> @@ _thStart <- \< th \> @@ _thEnd <- \< \/ th \> @@ _aStart <- \< a _xWILD [fail=(\>)] \> @@ _aEnd <- \< \/ a \> @@
@CODE L("debugpath") = G("$kbpath") + "debug.txt"; G("debug") = openfile(L("debugpath"),"app"); G("words") = findconcept(findroot(),"words"); if (!G("words")) G("words") = makeconcept(findroot(),"words"); #rmchildren(G("words")); G("stats") = findconcept(findroot(),"stats"); if (!G("stats")) G("stats") = makeconcep...
@PATH _ROOT _LINE # If there's a "The" before a cap phrase, add it in. # Reassess some things accordingly. # Need a function to find a good runner-up. # If it's humanname or job title, should trash those assignments. @PRE <1,1> cap(); @POST if (N("hi class",3) == "humanname" || N("hi class",3) == "job title") { ...
@CODE if (G("pretagged")) exitpass(); if (!G("hilite")) # 10/25/10 AM. exitpass(); # 10/25/10 AM. G("hello") = 0; @@CODE # Traverse the whole tree. @MULTI _ROOT @POST if (G("verbose")) "np.txt" << N("$text") << "\n"; noop(); # Merely matching the rule will set text to green. @RULES _xNIL <- _xWILD [one ma...
@NODES _term @POST X("code") = N("$text", 2); @RULES _xNIL <- _xSTART ### (1) _xNUM ### (2) \, ### (3) _xWILD @@
@NODES _ROOT @PRE <2,2> vargt("prose",2); @POST listadd(1,2,"false"); @RULES _xNIL <- _prose _LINE @@ @PRE <1,1> vargt("prose",2); <2,2> vargt("prose",2); @RULES _prose <- _LINE _LINE @@
@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 _areaCodes @POST L("areacodes") = getconcept(G("state"),"areacodes"); makeconcept(L("areacodes"),N("$text")); @RULES _xNIL <- _xNUM ### (1) @@
@NODES _LINE @POST X("start") = 1; single(); @RULES _start <- ind ### (1) attr ### (2) @@ @POST X("end") = 1; single(); @RULES _end <- end ### (1) ind ### (2) @@
@NODES _ROOT ################################################## # Lookup of character codes in &ALPHABETIC; format # (but not whitespace chars -- these are handled # in the rule block for whitespace ################################################## @POST G("root") = findroot() ; G("character_codes") = findconcept(...
@PATH _ROOT _paragraph _sentence @POST S("type") = "total"; single(); @RULES _operator <- a total of @@ @POST S("type") = ">"; single(); @RULES _operator <- more than @@
@NODES _LINE @RULES # Ex: afro\_\\-\_american\_and\_african\_studies _field [layer=(_Caps )] <- afro [s] _xWHITE [star s] \\ [s] \- [s] _xWHITE [star s] american [s] _xWHITE [star s] and [s] _xWHITE [star s] african [s] _xWHITE [star s] studies [s] @@ # Ex: finance\_\\,\_insurance\_and\_real _field [layer=(_Caps )] ...
# Fetch concept's list of attributes. L("return_attr") = findattrs(L("con"));
@NODES _ROOT @PRE <1,1> var("header"); @POST splice(1,1); @RULES _xNIL <- _LINE ### (1) @@
@POST rfarecurse(2, 3, 5) single() @RULES _RECURSE [base] <- _soRECURSE [s] _LIT _REGIONS [opt] _eoRECURSE [s] _LIT [opt] @@
@NODES _ROOT @RULES _headerClose <- \< \/ h 4 \> @@ _headerOpen <- \< h 4 \> @@ _bottom <- bottom \- horizontal @@
@NODES _split @POST L("code") = N("code", 1); L("term") = N("term", 1); if (strcontains(".", L("code"))) { L("codes") = split(L("code"), "."); if (strlength(L("codes")[1]) > 1) { addEntryToHier(X("con"), L("code"), L("term")); } } noop(); @RULES _xNIL <- _entry ### (1) @@
@NODES _LINE @RULES _item <- _xSTART ### (1) _xWILD [plus match=(\# \*)] ### (2) _xWILD [fail=(_xEND)] ### (3) @@
@CODE G("hello") = 0; @@CODE #@PATH _ROOT _TEXTZONE _noun _caps @NODES _caps # Want an _xFEAT match! @CHECK if (N("sem",3) != "person title") fail(); if (N("ne",4) || N("ne",5)) fail(); @POST L("tmp3") = N(3); group(4,5,"_np"); N("ne",4) = 1; N("ne type",4) = N("sem",4) = "person"; N("ne type c...
@PATH _ROOT _LINE _column @POST excise(1,1); noop(); @RULES _xNIL <- _xWHITE [s] ### (1) @@
@NODES _doctypedecl @RULES _DeclSep <- _PEReference [one] @@ _DeclSep <- _whiteSpace [one] @@ @@RULES
# Remove attributes and values of concept con's attribute named str. rmvals(L("con"), L("str"));
@NODES _ROOT @RULES _companySuffix <- _xWILD [one match=(inc llc)] ### (1) \. ### (2) @@ @RULES _number <- no ### (1) \. ### (2) @@ @RULES _paragraphSeparator <- \n [s min=2 max=0] ### (1) @@ @POST L("tmp") = N("$text",2) + "." + N("$text",4); S("value") = flt(L("tmp")); single(); @RULE...
@PATH _ROOT _educationZone _educationInstance _LINE # This one is for catching city turd to the right of school. # Accepting short turds, even if known words, that haven't been reduced # to anything. @POST if (!X("school",3)) X("school",3) = N("$text",1); if (N("unknowns",5) || (N("unreduced",5) && N("c...
@NODES _ROOT @RULES _xNIL <- _xNIL ### (1) @@
@NODES _ROOT @RULES _enum <- _beginEnum ### (1) _xWILD ### (2) _endEnum ### (3) @@
@NODES _ROOT @POST singler(1,2); @RULES _emptyItem [base] <- _enclosedBy ### (1) _enclosedBy ### (2) _xWILD [match=(_separator _lineTerminator _xEND)] ### (3) @@
@NODES _ROOT @POST S("text") = N("$text",3); single(); @RULES _comment <- \/ ### (1) \/ ### (2) _xWILD [fail=(\/ _pos)] ### (3) @@
@CODE G("filepath") = G("$apppath") + "\input\portverbs.txt"; "debug.txt" << G("filepath") << "\n"; if (G("$inputname") == "file001.txt") { G("file") = openfile(G("filepath")); } else { G("file") = openfile(G("filepath"),"app"); } @@CODE
@CODE fileout("lines1.txt"); # 06/10/00 AM. @@CODE # No way right now to initialize var in the context node. # Not in the current pass, anyway. # "nlines" will keep line count in every experience zone. @PATH _ROOT _experienceZone # Give each line a line number. @POST ++X("nlines"); N("lineno") = X("nlines"); # n...
@POST rfanodes(2, nodes) single() @RULES _NODES [base] <- _soNODES _NONLIT [star] _eoNODES [opt] @@
@DECL NepaliNum(L("numString")){ if (L("numString") == "१") return 1; else if (L("numString") == "२") return 2; else if (L("numString") == "३") return 3; } @@DECL
@NODES _LINE @RULES _indent <- _xSTART _xWILD [match=(_xWHITE)] @@