text
stringlengths 22
301k
|
---|
@NODES _LINE
@RULES
# Ex: Office:\_(
_phoneWorkPhrase <- _xWILD [min=1 max=1 s layer=("_Work") match=("Office" "Wk" "w" "O" "Work")] \: [s] _xWHITE [star s] _phoneNumber [s] _xWHITE [star s] _phoneExtension [s] @@
_phoneWorkPhrase <- _phoneNumber [s] _xWHITE [star s] _phoneExtension [s] _xWHITE [star s] _xWILD [min=1 max=1 s match=("_openPunct" "\(")] _xWILD [min=1 max=1 trig s layer=("_Work") match=("Office" "Wk" "O" "W" "work")] _xWILD [min=1 max=1 s match=("_closePunct" "\)")] @@
# Ex: Office:\_(
_phoneWorkPhrase <- _xWILD [min=1 max=1 s layer=("_Work") match=("Office" "Wk" "w" "O" "Work")] \: [s] _xWHITE [star s] _phoneNumber [s] @@
_phoneWorkPhrase <- _phoneNumber [s] _xWHITE [star s] _xWILD [min=1 max=1 s match=("_openPunct" "\(")] _xWILD [min=1 max=1 trig s layer=("_Work") match=("Office" "Wk" "O" "W" "work")] _xWILD [min=1 max=1 s match=("_closePunct" "\)")] @@
_phoneWorkPhrase <- _phoneNumber [s] _xWHITE [star s] _phoneExtension [s] _xWHITE [star s] _xWILD [min=1 max=1 trig s layer=("_Work") match=("Office" "Wk" "O" "W" "work")] @@
_phoneWorkPhrase <- _phoneNumber [s] _xWHITE [star s] _xWILD [min=1 max=1 trig s layer=("_Work") match=("Office" "Wk" "O" "W" "work")] @@
# Ex: (office)\_(
_phoneWorkPhrase <- _xWILD [min=1 max=1 s match=("_openPunct" "\(")] _xWILD [min=1 max=1 trig s layer=("_Work") match=("office" "Wk" "W" "O" "Work")] _xWILD [min=1 max=1 s match=("_closePunct" "\)")] _xWHITE [star s] _phoneNumber [s] _xWHITE [star s] _phoneExtension [s] @@
# Ex: (office)\_(
_phoneWorkPhrase <- _xWILD [min=1 max=1 s match=("_openPunct" "\(")] _xWILD [min=1 max=1 trig s layer=("_Work") match=("office" "Wk" "W" "O" "Work")] _xWILD [min=1 max=1 s match=("_closePunct" "\)")] _xWHITE [star s] _phoneNumber [s] @@
_phoneWorkPhrase <- _phoneNumber [s] _xWHITE [star s] _phoneExtension [s] @@
|
@DECL
FileNameNumbered(L("name"),L("zero count")) {
L("c") = 0;
L("stop") = L("zero count") - strlength(str(G("counter"))) + 1;
while (L("c") < L("stop")) {
L("zeroes") = L("zeroes") + "0";
L("c")++;
}
L("filename") = G("$apppath") + "/files/" + L("name") + L("zeroes") + str(G("counter")) + ".txt";
"debug.txt" << L("filename");
return L("filename");
}
@@DECL |
@NODES _ROOT
@PRE
<1,1> var("word");
<1,1> var("female");
<1,1> varz("male");
@POST
"output.txt" << N("word") << " female\n";
@RULES
_xNIL <-
_LINE ### (1)
@@
|
@CODE
L("hello") = 0;
if (!G("hilite"))
exitpass();
@@CODE
# Traverse the whole tree.
@MULTI _ROOT
@PRE
<1,1> var("mypos");
#<1,1> var("pos_np");
@POST
noop(); # Merely matching the rule will set text to green.
@RULES
_xNIL <- _xANY @@
|
@CODE
DispKB();
@@CODE |
@POST
excise(1, 1)
noop()
@RULES
_xNIL <- \, [plus] @@
|
@DECL
# EUIToCodes
# Gets all codes for EUI
GetCodes(L("eui")) {
L("eui_con") = findconcept(G("eui_to_codes"), L("eui"));
if (L("eui_con")) {
L("return_vals") = findvals(L("eui_con"), "codes");
return L("return_vals");
}
else {
return 0;
}
}
# AddVals
# Add string vals to attribute of concept
AddVals(L("con"), L("attr_name"), L("vals")) {
while (L("vals")) {
addstrval(L("con"), L("attr_name"), getstrval(L("vals")));
L("vals") = nextval(L("vals"));
}
}
# rankCode
# Rank code by calculating
# (bases in code) / (bases in note section)
# Args
# code: code to rank
# note_euis: list of euis from note to rank
rankCode(L("code"), L("note_euis")) {
# Lookup code in KB
L("code_con") = findconcept(G("code_to_euis"), L("code"));
if (!L("code_con")) {
"debug.txt" << "Warning: no concept in <code_to_euis> for code " << L("code") << "\n";
return 0;
}
"debug_rank.txt" << "# " << L("code") << "\n";
L("code_euis") = findvals(L("code_con"), "euis");
L("eui_arr") = StrValsToArray(L("code_euis"));
L("note_euis") = FilterDuplicates(L("note_euis"), 0);
# Get number of euis represented in code
L("total_code_euis") = arraylength(L("eui_arr"));
L("total_code_euis") = 0;
# Iterate over code euis
L("rank") = 0;
L("euis_found") = 0;
L("code_eui_iter") = L("code_euis");
"debug_rank.txt" << getstrval(L("code_eui_iter")) << "\n";
while (L("code_eui_iter")) {
L("curr_eui") = getstrval(L("code_eui_iter"));
# Search for current euis in (sorted) note euis,
L("in_notes") = BinarySearch(L("note_euis"), L("curr_eui"));
"debug_rank.txt" << L("curr_eui") << "\n";
L("not_found") = -1; # Need to store as variable for comparison
if (1) {
# Weight euis based on frequency of occurence in codes (higher frequency = lower weight)
# Get eui frequency (or probability)
"debug_division.txt" << "Eui " << L("curr_eui") << " at index " << L("in_notes") << "\n";
L("p_eui_con") = getconcept(G("P_eui"), L("curr_eui"));
if (!L("p_eui_con")) {
"debug_division.txt" << "\t Warning: No p_eui concept found.";
}
else {
"debug_division.txt" << "\tRetrieved concept: " << conceptname(L("p_eui_con")) << "\n";
}
L("freq_attr") = findattrs(L("p_eui_con"));
L("freq") = getsval(attrvals(L("freq_attr")));
"debug_division.txt" << L("freq") << "\n";
# debug
L("all_attrs") = findattrs(L("p_eui_con"));
while (L("all_attrs")){
"debug_division.txt" << "\Eui attrs: " << attrname(L("all_attrs")) << "\n";
L("all_attrs") = nextattr(L("all_attrs"));
}
"debug_division.txt" << "\tFrequency: " << L("freq") << "\n";
"debug_division.txt" << "\tFrequency: " << flt(L("freq")) << "\n";
L("weight") = 1.0 / flt(L("freq"));
"weights.txt" << L("weight") << "\n";
L("total_code_euis") = flt(L("total_code_euis")) + L("weight");
if (L("in_notes") != L("not_found")) {
L("euis_found") = flt(L("euis_found")) + L("weight");
}
# Alternatively, increment euis_found
# L("euis_found")++;
}
L("code_eui_iter") = nextval(L("code_eui_iter"));
}
# Rank = |intersection(euis in note, euis in code)| / |euis in code|
if (L("total_code_euis") == 0) {
return 0;
}
L("rank") = flt(L("euis_found")) / flt(L("total_code_euis"));
# # Alternatively, simply set to num euis found.
# L("rank") = L("euis_found");
# "ranks.txt" << L("euis_found") << " / " << L("total_code_euis") << " code euis";
"ranks.txt" << " = " << L("rank") << "\n";
return L("rank");
}
# extractCodeRanks
# Takes a set of key words from a note, finds plausible keywords,
# then appends code predictions to KB with ranking
# Params:
# keys: List of keys from a given section
# type: procedure/diagnosis split
# Return:
# null, non-zero ranked codes and ranks will be added to kb
# extractCodeRanks(L("keys"), L("type")) {
# L("i") = 0;
# while (L("i") < arraylength(L("keys"))) {
# L("key") = L("keys")[L("i")];
# L("first_code") = keyToCodes(L("key"));
# # Loop over each code which contains current key word
# L("code_iter") = L("first_code");
# while (L("code_iter")) {
# L("code") = conceptname(L("code_iter"));
# L("rank") = rankCode(L("code"), L("keys"), L("type"));
# "codes.txt" << L("code") << ", rank: " << L("rank") << "\n";
# # FIXME: Add logic to partition into relevant split (proc or diag)
# if (flt(L("rank")) != 0.0) {
# if (L("type") == "diagnoses") {
# L("con") = AddUniqueCon(G("pred_diagnoses"), L("code"));
# addstrval(L("con"), "rank", str(L("rank")));
# }
# else if (L("type") == "procedures") {
# L("con") = AddUniqueCon(G("pred_procedures"), L("code"));
# addstrval(L("con"), "rank", str(L("rank")));
# }
# }
# L("code_iter") = next(L("code_iter"));
# }
# L("i")++;
# }
# }
# getFloatSum
# Params:
# L("list"): list of float vals stored as strings
# Returns:
# Sum of list as float
getFloatSum(L("list")) {
L("sum") = 0.0;
while (L("list")) {
L("sum") = L("sum") + flt(getstrval(L("list")));
"sums.txt" << flt(getstrval(L("list"))) << "\n";
L("list") = nextval(L("list"));
}
return L("sum");
}
# sumRanks
# Params:
# L("first_code"): first code with rank attribute
# the next siblings will also be summed
# Returns:
# Null. After calling, sums =
sumRanks(L("first_code")) {
L("iter_code") = L("first_code");
while (L("iter_code")) {
L("rank") = attrvals(findattr(L("iter_code"), "rank"));
L("rank_sum") = getFloatSum(L("rank"));
replaceval(L("iter_code"), "rank", L("rank_sum"));
L("iter_code") = next(L("iter_code"));
}
}
convertToInt(L("first_code"), L("shift")) {
L("iter_code") = L("first_code");
while (L("iter_code")) {
L("rank") = fltval(L("iter_code"), "rank");
L("shifted") = str(L("rank") * L("shift"));
L("split") = split(L("shifted"), ".");
L("int") = num(L("split")[0]);
replaceval(L("iter_code"), "rank", L("int"));
L("iter_code") = next(L("iter_code"));
}
}
# getChildCons
# (concepts, not convicts)
# Params:
# parent_con: parent concept with children concepts to sort
# Returns:
# List of child concepts of parent_con of type con if not str, else string
getChildCons(L("parent_con"), L("str")) {
L("children") = 0;
L("iter") = down(L("parent_con"));
while (L("iter")) {
if (L("children")) {
if (L("str")) {
L("children")[arraylength(L("children"))] = conceptname(L("iter"));
}
else {
L("children")[arraylength(L("children"))] = L("iter");
}
}
else {
if (L("str")) {
L("children") = conceptname(L("iter"));
}
else {
L("children") = L("iter");
}
}
L("iter") = next(L("iter"));
}
return L("children");
}
@@DECL |
@CODE
# Traverse top split of eui_to_codes concept, saving sum total
# and adding eui/count to kb
G("top_eui_sum") = 0;
G("top_eui_exp_sum") = 0;
L("iter") = down(G("eui_to_codes_top"));
while (L("iter")) {
# Get all codes for eui
L("codes") = findvals(L("iter"), "codes");
# Create concept for code in P_eui
L("eui_con") = makeconcept(G("P_eui_top"), conceptname(L("iter")));
# Get number of codes in codes attribute
L("num_codes") = ValsLength(L("codes"));
# Add to sum total
G("top_eui_sum") = G("top_eui_sum") + L("num_codes");
# Add to exp total (softmax denominator)
G("top_eui_exp_sum") = flt(G("top_eui_exp_sum")) + exp(L("num_codes"));
# Add to numval
addnumval(L("eui_con"), "codes", L("num_codes"));
# Advance iterator to sibling concept
L("iter") = next(L("iter"));
}
"p_top.txt" << "\nTotal sum: " << G("top_eui_sum") << "\n";
"p_top.txt" << "Total exp sum: " << G("top_eui_exp_sum") << "\n\n";
L("iter") = down(G("P_eui_top"));
while (L("iter")) {
# Get codes attribute
L("frequency") = numval(L("iter"), "codes");
# # Calculate exp(eui) / (sum to j [exp(eui_j)])
# L("exp_n") = flt(exp(L("frequency")))
# L("p") = L("exp_n") / flt(G("top_eui_exp_sum"));
# "p_top.txt" << conceptname(L("iter")) << ": " << L("exp_n") << " / total = " << L("p") << "\n";
# Add p as attribute under eui
addstrval(L("iter"), "p", str(L("p")));
# Advance iterator to next sibling
L("iter") = next(L("iter"));
}
@@CODE |
# To demonstrate nextattr, we first need to build a KB:
if (findconcept(findroot(),"apple"))
rmconcept(findconcept(findroot(),"apple"));
# Create the apple concept
G("apple") = makeconcept(findroot(),"apple");
# Apples have color
addstrval(G("apple"),"have","color");
# Apple's color is red
addstrval(G("apple"),"color","red");
# Apple's weigh 3 something or others
addnumval(G("apple"),"weight",3);
# Apple's color is also green and yellow
addstrval(G("apple"),"color","green and yellow");
The code creates a KB like this:
|
@NODES _ROOT
@RULES
## Changed this from _BLANKLINE to _LINE from library Lines.pat
_LINE <-
_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)
@@
|
@NODES _ROOT
@POST
L("con") = AddUniqueCon(G("pos"),N("$text",3));
"pos.txt" << N("$text",3) << "\n";
IncrementCount(L("con"),"count");
@RULES
_xNIL <-
pos ### (1)
\= ### (2)
_xALPHA ### (3)
@@
|
@NODES _ROOT
@POST
# Saving code, but not adding to KB, so we can put it in order later
S("code") = AddUniqueCon(G("icd_codes"), N("$text", 1));
addstrval(S("code"), "term", N("$text", 3));
# S("code") = N("$text", 1);
excise(4,4);
excise(1,2);
single();
@RULES
_entry<-
_xWILD [fails=(\t)] ### (1)
\t ### (2)
_xWILD [fails=(\n \r)] ### (3)
_xWILD [one matches=(\n \r)] ### (4)
@@ |
@CODE
# Replace "labels.kb" with file path to store in different dir
#kbdumptree(G("labels"), "labels.kb");
#DumpKB(G("root"), "ICD");
DisplayKB(G("root"),1);
@@CODE
|
@NODES _LINE
@POST
X("code") = N("$text",1);
@RULES
_xNIL <-
_code
@@ |
# Lookup all the values in the words variable in the dict.words file
@CODE
G("Words")[0] = "aardvark";
G("Words")[1] = "abacus";
gtolower("Words");
sortvals("Words");
guniq("Words");
lookup("Words","dict.words","word");
@PRE
<1,1> unknown();
@POST
N("unknown word") = 1;
@RULES
_xNIL <- _xALPHA @@ |
@NODES _LINE
# No intervening whitespace. "retokenization".
@POST
S("len") = 2;
S("puncts") = 1; # 01/11/00 AM.
single();
@RULES
_Caps [unsealed] <- _xCAP [s] _xWILD [s one match=( \- \/ )] _xCAP [s] @@
# Some special names.
# Ex, O'Henry.
@RULES
_surName [layer=(_humanNamepart _Caps)] <-
O [s]
_xWILD [s one match=( \' \~ )]
_xCAP [s] @@
# VARIOUS POSSESSIVES, etc. John's, Peoples'.
@POST
S("len") = 1;
single();
@RULES
_Caps [unsealed] <- _xCAP [s] \' [s] _xALPHA [s opt] @@
# E.g., Southern California.
@POST
S("len") = 2;
S("state") = N("$text",3);
single();
@RULES
_Caps [unsealed] <-
_adjDirection [s] _xWHITE [s star] _state [s] @@
# Preempt caps formation for some stuff.
@POST
S("city") = N("$text",1);
S("state") = N("$text",4);
single();
@RULES
_cityState <- _city [s] \, [s opt] _xWHITE [s star] _state [s] @@
# Take a look at some other city-state candidates.
#@PRE
#<1,1> unknown();
#<3,3> unknown();
@CHECK # 09/02/01 AM.
if (spellword(N("$text",1)) || spellword(N("$text",3)))
fail();
@POST
S("state") = N("$text",6);
group(1,3,"_city");
S("city") = N("$text",1); # group changes numbering.
single();
@RULES
_cityState <-
_xCAP [s]
_xWHITE [s star]
_xCAP [s]
\, [s]
_xWHITE [s star]
_state [s trig]
@@
#@PRE
#<1,1> unknown();
@CHECK
if (spellword(N("$text",1)))
fail();
@POST
S("state") = N("$text",4);
S("city") = N("$text",1);
single();
@RULES
_cityState <-
_xCAP [s layer=(_city)]
\, [s]
_xWHITE [s star]
_state [s trig]
@@
|
@NODES _ROOT
@RULES
_nameToken <- _xNUM _xCAP @@
@RULES
_USA <- U \. S \. A \. @@
_USA <- U \. S \. @@
_AKA <- a \. k \. a \. @@
_AKA <- aka @@
_ST <- st \. @@
_month <-
_xWILD [one match=(
jan
feb
mar
apr
jun
jul
aug
sept
oct
nov
dec
)]
\.
@@
_quote <-
_xWILD [one match=(\' \")] ### (1)
@@
_nameSuffix <-
_xWILD [match=(_xWHITE \,)] ### (1)
_xWILD [one match=(jr sr i ii iii)] ### (2)
\. ### (3)
@@
_nameAbbrevCandidate <-
_xCAPLET [s] ### (1)
\. ### (2)
@@
|
# Rename every node that matched the current element to NAME
@RULES
_locfield <- location \: _xWILD [ren=_location] \n @@ |
@NODES _ROOT
@CHECK
if (N("count",1) == G("max header"))
succeed();
fail();
@POST
"nesting.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") < 1)
exitpass();
"nesting.txt" << "max: " << G("max header") << "\n";
@RULES
_xNIL <-
_xWILD [match=(_LINE _headerZone)]
_xEND
@@
|
@NODES _LINE
@POST
L("header") = N("$text",2);
S("header") = L("header");
X("header") = 1;
S("count") = strlength(N("$text",1));
if (S("count") > G("max header")) {
G("max header") = S("count");
}
"header.txt" << L("header") << " " << str(S("count")) << "\n";
single();
@RULES
_header <-
_xWILD [min=1 match=(\#)] ### (1)
_xWILD [plus fail=(_xEND)] ### (2)
@@
|
@NODES _ROOT
@RULES
_tdOpen <- \< td _xWILD [fail=(\>)] \> @@
_tdClose <- \< \/ td \> @@
|
# Match a _verb node optionally preceded by _modal, _have, or _be nodes, reducing to _vgroup
@RULES
_vgroup <- _modal [opt]
_have [opt] _be [opt]
_verb @@ |
@PATH _ROOT _paragraph _sentence
@POST
S("title") = N("$text",3);
single();
@RULES
_titleParen <-
\( ### (1)
a ### (2)
_agency ### (3)
\) ### (4)
@@
|
@NODES _ROOT
@RULES
_xNIL <-
_xNIL ### (1)
@@
|
# Do a mini-reduction of all the nodes that matched _noun, naming the
@RULES
_np <- _det
_quan _adj _noun [plus group=_nouns] @@ |
@NODES _ROOT
@POST
PathToConcept(G("kb"),N("con"));
@RULES
_xNIL <-
_LINE ### (1)
@@
|
@PATH _ROOT _paragraph _sentence
@POST
L("con") = getconcept(G("caps"),N("$text"));
S("caps") = L("con");
AddUniqueStr(L("con"),"type","full");
single();
@RULES
_name <-
_xWILD [min=2 match=(_xCAP)]
@@
@PRE
<1,1> uppercase();
@POST
L("con") = getconcept(G("caps"),N("$text"));
S("caps") = L("con");
AddUniqueStr(L("con"),"type","abbrev");
# L("name") = makeconcept(X("sent",3),N("$text"));
# addconval(L("name"),"caps",L("con"));
single();
@RULES
_name <-
_xALPHA
@@
|
@CODE
TakeKB("phrases");
G("phrases") = findconcept(findroot(), "phrases");
@@CODE
|
@NODES _ROOT
@RULES
_BLANKLINE <-
_xWILD [min=0 max=0 matches=(\ \t \r)] ### (1)
\n ### (2)
@@
@POST
S("con") = MakeCountCon(G("sentences"),"sentence");
single();
@RULES
_LINE <-
_xWILD [min=0 max=0 fails=(\r \n)] ### (1)
_xWILD [one match=(\n _xEND)] ### (2)
@@
|
@PATH _ROOT _LINE _Caps
# Job title root word (eg, "programmer") at the end of phrase
# gets a bonus.
@POST
++X("jobtitleroots"); # Bump in _Caps context node.
if (N("$end")) # If last node in caps phrase.
++X("end jobtitleroot"); # Bonus. Last word in cap phrase.
# noop() # Implicit.
@RULES
_xNIL <- _jobTitleRoot [s] @@
_xNIL <- _jobPhrase [s] @@ # 12/26/99 AM.
_xNIL <- _jobTitle [s] @@ # 01/01/00 AM.
@POST
++X("jobmods"); # Bump in _Caps context node.
if (N("$end")) # If last node in caps phrase.
++X("end jobmod"); # Bonus. Last word in cap phrase.
# noop() # Implicit.
@RULES
_xNIL <- _jobMod [s] @@
|
@NODES _ROOT
@RULES
_section <-
_xWILD [min=2 matches=(\n \r)]
@@
|
@NODES _LINE
@RULES
_degree <-
_xWILD [s one match=(Bachelor Master Bachelors Masters)]
_xWHITE [s star]
Degree [s]
@@
_degree <-
_xWILD [s one match=(Bachelor Master)]
\' [s]
s [s]
_xWHITE [s star]
Degree [s]
@@
_degree <-
_xWILD [s one match=(Bachelor Bachelors Master Masters)]
_xWHITE [s star]
of [s]
_xWHITE [s star]
_xWILD [s one match=(Art Arts Science Sciences)]
@@
_degree <-
_xWILD [s one match=(Bachelor Master )]
\' [s]
s [s]
_xWHITE [s star]
of [s]
_xWHITE [s star]
_xWILD [s one match=(Art Arts Science Sciences)]
@@
#_degree [] <- _xWILD [s t one match = ( graduate graduated )]
# _xWHITE [s opt]
# _xWILD [s opt match = ( of from )]
# @@
_degree [] <-
_xWILD [s t one match = (Associate Bachelor Master )]
\' [s]
s [s]
@@
_degree [] <- _xWILD [s one match = (
Associate
Associates
Bachelor
Bachelors
Masters
Master
Doctorate
diploma
certificate
senior
junior
sophmore
freshman
#certified
)] @@
_degree [] <- _xWILD [s one match = ( A Advanced )]
_xWHITE [s]
_xWILD [s one match = ( Levels Level )] @@
|
@NODES _LINE
@PRE
<1,1> cap()
<1,1> length(4)
<3,3> cap()
<3,3> length(5)
@RULES
# Ex: West\_Point
_university <- _xWILD [min=1 max=1 s match=(_cityMod _companyMod _jobMod _Direction West)] _xWHITE [star s] _xWILD [min=1 max=1 s match=(_PostalRoad Point)] @@
@PRE
<1,1> cap()
<1,1> length(1)
<3,3> cap()
<3,3> length(1)
<5,5> cap()
<5,5> length(1)
@RULES
# Ex: S.M.U.
_university <- _xALPHA [s] \. [trig s] _xALPHA [s] \. [s] _xALPHA [s] \. [s] @@
@PRE
<1,1> cap()
<1,1> length(1)
<3,3> cap()
<3,3> length(1)
<5,5> cap()
<5,5> length(1)
<7,7> cap()
<7,7> length(1)
@RULES
# Ex: U.C.S.B.
_university <- _xALPHA [s] \. [s] _xALPHA [s] \. [s] _xWILD [min=1 max=1 trig s match=(_Direction S)] \. [s] _xALPHA [s] \. [s] @@
@PRE
<1,1> cap()
<1,1> length(1)
<3,3> cap()
<3,3> length(4)
@RULES
# Ex: U.PENN
_university <- U [s] \. [s] _xALPHA [s] @@
@PRE
<1,1> cap()
<1,1> length(1)
<3,3> cap()
<3,3> length(1)
@RULES
# Ex: U.C.
_university <- U [s] \. [s] _xALPHA [s] \. [s] @@
|
@NODES _ROOT
@POST
"header.txt" << N("$text",2) << "\n\n";
S("text") = N("$text",2);
single();
@RULES
_header <-
_headerOpen ### (1)
_xWILD [fail=(_headerClose)] ### (2)
_headerClose ### (3)
@@
|
@NODES _LINE
@PRE
<1,1> cap();
@RULES
# Ex: Media
_companyMod <- _xWILD [min=1 max=1 s match=("Media" "Advanced" "Air" "America" "American" "Apparel" "Applied" "Atlantic" "Auto"
"Automotive" "Bio" "Business" "Capital" "Care" "Cellular" "Central" "China" "City" "Computer"
"Consolidated" "Control" "Crown" "Data" "De" "Dental" "Design" "Development" "Digital" "Eagle"
"Environmental" "Exploration" "First" "Food" "Furniture" "Gold" "Golf" "Home" "Hospitality" "Information"
"Integrated" "Internet" "Laser" "Learning" "Life" "Management" "Marine" "Access" "Motor" "National"
"Natural" "Net" "Network" "New" "North" "Oil" "One" "Pacific" "Park" "Penn"
"Phoenix" "Pioneer" "Power" "Precision" "Premier" "Public" "Resorts" "Restaurant" "Science" "Sciences"
"Scientific" "Security" "Southern" "Specialty" "Sports" "Standard" "Star" "Steel" "Tele" "Thermo"
"Transport" "Transportation" "USA" "Valley" "Video" "Vision" "Waste" "Water" "West" "Western"
"Wireless" "World" "Worldwide")] @@
|
## CODE REGION
@CODE
prlit("output.txt","\n");
prlit("output.txt","EXPERIENCE:\n");
@@CODE
@PATH _ROOT _experienceZone
@CHECK
# Require the instance to have a daterange.
if (!N("date range",1)) fail();
@POST
if(N("date range")){
"output.txt"
<< LJ("Date:",G("indent"))
<< N("date range",1)
<< "\n";
}
if(N("company name")){
"output.txt"
<< LJ("Company:",G("indent"))
<< N("company name",1)
<< "\n";
}
if(N("job title")){
"output.txt"
<< LJ("Position:",G("indent"))
<< N("job title",1)
<< "\n";
}
if (N("city"))
{
if (N("state"))
N("loc") = N("city") + ", " + N("state");
else if (N("country"))
N("loc") = N("city") + ", " + N("country");
else
N("loc") = N("city");
}
else if (N("state"))
N("loc") = N("state");
else if (N("country"))
N("loc") = N("country");
if (N("loc")){
"output.txt"
<< LJ("Location:",G("indent"))
<< N("loc",1)
<< "\n";
}
"output.txt" << "\n"; # 11/22/00 AM.
@RULES
_xNIL <- _experienceInstance @@ |
# Allocate 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 _LINE
@RULES
# ex. Linguistics and Philosophy
_major [] <- _major [s]
_xWHITE [s]
_xWILD [s one matches = ( and \& ) ]
_xWHITE [s]
_major [s]
@@
# ex. Linguistics, Philosophy
_major [] <- _major [s]
_xWILD [s one matches = ( \,) ]
_xWHITE [s]
_major [s]
@@
# ex. Linguistics, Philosophy, Computer Science
_major [] <- _major [s]
_xWILD [s one matches = ( \,) ]
_xWHITE [s]
_xWILD [s one matches = ( \,) ]
_xWHITE [s]
_major [s]
@@ |
@PATH _ROOT _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("buffer2"))
S("EntityName") = S("buffer2") ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
if (G("CurrentEntity") == 0 ) {
makeconcept(G("Entities"),S("EntityName")) ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
}
addattr(G("CurrentEntity"),"parameter") ;
addsval(G("CurrentEntity"),"parameter",1) ;
addattr(G("CurrentEntity"),"internal") ;
addsval(G("CurrentEntity"),"internal",0) ;
addattr(G("CurrentEntity"),"textValue") ;
addattr(G("CurrentEntity"),"URI") ;
addstrval(G("CurrentEntity"),"URI",str(N("URI",7))) ;
single() ;
@@POST
@RULES
_PEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s trig min=1 max=1 matches=("\%")] ### (2)
_whiteSpace [opt] ### (3)
_xWILD [s min=1 max=1 matches=("_xALPHA" "_" ":")] ### (4)
_xWILD [s min=0 max=0 matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (5)
_whiteSpace [opt] ### (6)
_ExternalID [one] ### (7)
@@
@@RULES
@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("buffer2"))
S("EntityName") = S("buffer2") ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
if (G("CurrentEntity") == 0 ) {
makeconcept(G("Entities"),S("EntityName")) ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
}
addattr(G("CurrentEntity"),"parameter") ;
addsval(G("CurrentEntity"),"parameter",1) ;
addattr(G("CurrentEntity"),"internal") ;
addsval(G("CurrentEntity"),"internal",1) ;
addattr(G("CurrentEntity"),"textValue") ;
addstrval(G("CurrentEntity"),"textValue",str(N("textValue",7))) ;
single() ;
@@POST
@RULES
_PEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s trig one matches=("\%")] ### (2)
_whiteSpace [opt] ### (3)
_xWILD [s one matches=("_xALPHA" "_" ":")] ### (4)
_xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (5)
_whiteSpace [opt] ### (6)
_EntityRef [one] ### (7)
@@
_PEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s trig min=1 max=1 matches=("\%")] ### (2)
_whiteSpace [opt] ### (3)
_xWILD [s min=1 max=1 matches=("_xALPHA" "_" ":")] ### (4)
_xWILD [s min=0 max=0 matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (5)
_whiteSpace [opt] ### (6)
_PEReference [one] ### (7)
@@
@@RULES
@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("buffer2"))
S("EntityName") = S("buffer2") ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
if (G("CurrentEntity") == 0 ) {
makeconcept(G("Entities"),S("EntityName")) ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
}
addattr(G("CurrentEntity"),"parameter") ;
addsval(G("CurrentEntity"),"parameter",1) ;
addattr(G("CurrentEntity"),"internal") ;
addsval(G("CurrentEntity"),"internal",1) ;
addattr(G("CurrentEntity"),"textValue") ;
addstrval(G("CurrentEntity"),"textValue",str(N("textValue",7))) ;
single() ;
@@POST
@RULES
_PEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s trig one matches=("\%")] ### (2)
_whiteSpace [opt] ### (3)
_xWILD [s min=1 max=1 matches=("_xALPHA" "_" ":")] ### (4)
_xWILD [s min=0 max=0 matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (5)
_whiteSpace [opt] ### (6)
_PubidLiteral [one] ### (7)
@@
_PEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s trig min=1 max=1 matches=("\%")] ### (2)
_whiteSpace [opt] ### (3)
_xWILD [s min=1 max=1 matches=("_xALPHA" "_" ":")] ### (4)
_xWILD [s min=0 max=0 matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (5)
_whiteSpace [opt] ### (6)
_SystemLiteral [one] ### (7)
@@
@@RULES
@POST
if (N("$text",2))
S("buffer1") = str(N("$text",2)) ;
if (N("$text",3))
S("buffer2") = str(N("$text",3)) ;
if (N("$text",2) && N("$text",3)) {
S("EntityName") = S("buffer1") + S("buffer2") ;
}
else if (N("$text",2))
S("EntityName") = S("buffer1") ;
else if (N("$text",3))
S("EntityName") = S("buffer2") ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
if (G("CurrentEntity") == 0 ) {
makeconcept(G("Entities"),S("EntityName")) ;
G("CurrentEntity") = findconcept(G("Entities"),S("EntityName")) ;
}
addattr(G("CurrentEntity"),"parameter") ;
addsval(G("CurrentEntity"),"parameter",0) ;
addattr(G("CurrentEntity"),"internal") ;
addsval(G("CurrentEntity"),"internal",1) ;
addattr(G("CurrentEntity"),"textValue") ;
addstrval(G("CurrentEntity"),"textValue",str(N("textValue",5))) ;
single() ;
@@POST
@RULES
_GEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s one matches=("_xALPHA" "_" ":")] ### (2)
_xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3)
_whiteSpace [opt] ### (4)
_PubidLiteral [one] ### (5)
@@
_GEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s one matches=("_xALPHA" "_" ":")] ### (2)
_xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3)
_whiteSpace [opt] ### (4)
_SystemLiteral [one] ### (5)
@@
_GEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s one matches=("_xALPHA" "_" ":")] ### (2)
_xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3)
_whiteSpace [opt] ### (4)
_EntityRef [one] ### (5)
@@
_GEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s one matches=("_xALPHA" "_" ":")] ### (2)
_xWILD [s star matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3)
_whiteSpace [opt] ### (4)
_PEReference [one] ### (5)
@@
_GEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s one matches=("_xALPHA" "_" ":")] ### (2)
_xWILD [s opt matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3)
_whiteSpace [opt] ### (4)
_PubidLiteral [one] ### (5)
@@
_GEDecl <-
_whiteSpace [opt] ### (1)
_xWILD [s one matches=("_xALPHA" "_" ":")] ### (2)
_xWILD [s opt matches=("_xALPHA" "_xNUM" "." "-" "_" ":")] ### (3)
_whiteSpace [opt] ### (4)
_SystemLiteral [one] ### (5)
@@
@@RULES
|
@NODES _LINE
@RULES
_item <-
_comma ### (1)
@@
|
@NODES _ROOT
@POST
excise(1,3);
noop();
@RULES
_xNIL <-
RID ### (1)
_xNUM ### (2)
\n [opt] ### (3)
@@
|
# Fetch the float-value of a kb attribute attrName belonging to concept concept. If there are multiple numeric values, only the first value is returned
@CODE
L("pi") = makeconcept(findroot(), "pi");
replaceval(L("pi"),"val",3.14);
"output.txt" << "pi = " << fltval(L("pi"), "val") << "\n"; |
@NODES _ROOT
@POST
if (N("$text", 4)) {
S("code") = str(N("$text", 4)) + str(N("$text", 5));
}
else {
S("code") = str(N("$text", 5));
}
S("type") = N("$text", 9);
excise(2,9);
single();
@RULES
_term <-
_xWILD [fail=(code)] ### (1)
_xWILD [one matches=(code)] ### (2)
\= ### (3)
_xLET [opt] ### (4)
_xANY ### (5)
_xWHITE ### (6)
_xWILD [one matches=(type)] ### (7)
\= ### (8)
_xANY ### (9)
_xWILD [one matches=(\n \r _xEND)] ### (10)
@@ |
@CODE
G("parse") = getconcept(findroot(),"parse");
@@CODE |
@NODES _ROOT
# ONLINE HELP:
# http://visualtext.org/help/NLP_PP_Stuff/Phrase_element_modifiers.htm
@RULES
_np <-
_det ### (1)
_adj [optional] ### (2)
_noun [trig] ### (3)
@@ |
@NODES _LINE
@POST
X("concept") = N("$text",2);
@RULES
_xNIL <-
\" ### (1)
_xWILD [fails=(\")] ### (2)
\" ### (3)
_xEND ### (4)
@@
|
@CODE
G("kb") = getconcept(findroot(),"kb");
@@CODE |
@CODE
if (!G("pretagged"))
exitpass();
@@CODE
@NODES _ROOT
@POST
splice(1,1);
@RULES
_xNIL <-
_text
@@
@POST
excise(1,1);
@RULES
_xNIL <-
_slash
@@
|
# Make a phrase in con by creating named node.
L("return_phr") = makephrase(L("con"), L("name")); |
@CODE
L("hello") = 0;
@@CODE
#@PATH _ROOT _TEXTZONE _sent _clause
@NODES _clause
@POST
X("stuff-in-clause") = 1;
noop();
@RULES
_xNIL <- _xWILD [one match=(
_xALPHA _seg _tok _aposS
_noun _verb _adj _adv _premod
_interj
# _prep
_xNUM _xPUNCT
)] @@
# Funny things to check on.
_xNIL <-
_vg
_vg
@@
|
@NODES _LINE
@PRE
<1,1> cap();
<4,4> cap();
<7,7> cap();
<10,10> cap();
@RULES
# Ex: B.\_S.\_E.\_E.
_degreeInMajor <- B [s] \. [s] _xWHITE [star s] S [s] \. [s] _xWHITE [star s] E [s] \. [s] _xWHITE [star s] E [s] \. [s] @@
# Ex: B.\_S.\_C.\_S.
_degreeInMajor <- B [s] \. [s] _xWHITE [star s] S [s] \. [s] _xWHITE [star s] C [s] \. [s] _xWHITE [star s] S [s] \. [s] @@
# Ex: M.\_S.\_E.\_E.
_degreeInMajor <- M [s] \. [s] _xWHITE [star s] S [s] \. [s] _xWHITE [star s] E [s] \. [s] _xWHITE [star s] E [s] \. [s] @@
# Ex: M.\_S.\_C.\_S.
_degreeInMajor <- M [s] \. [s] _xWHITE [star s] S [s] \. [s] _xWHITE [star s] C [s] \. [s] _xWHITE [star s] S [s] \. [s] @@
@PRE
<1,1> cap();
<4,4> cap();
<7,7> cap();
@RULES
# Ex: B.\_B.\_A.
_degreeInMajor <- B [s] \. [s] _xWHITE [star s] B [s] \. [s] _xWHITE [star s] A [s] \. [s] @@
# Ex: M.\_B.\_A.
_degreeInMajor <- M [s] \. [s] _xWHITE [star s] B [s] \. [s] _xWHITE [star s] A [s] \. [s] @@
# Ex: M.\_S.\_W.
_degreeInMajor <- M [s] \. [s] _xWHITE [star s] S [s] \. [s] _xWHITE [star s] W [s] \. [s] @@
@PRE
<1,1> cap();
<3,3> cap();
<5,5> cap();
<7,7> cap();
@RULES
# Ex: B.S.E.E.
_degreeInMajor <- B [s] \. [s] S [s] \. [s] E [s] \. [s] E [s] \. [s] @@
# Ex: B.S.C.S.
_degreeInMajor <- B [s] \. [s] S [s] \. [s] C [s] \. [s] S [s] \. [s] @@
# Ex: M.S.E.E.
_degreeInMajor <- M [s] \. [s] S [s] \. [s] E [s] \. [s] E [s] \. [s] @@
@RULES
# Ex: M.S.C.S.
_degreeInMajor <- _degreeInMajor [s] @@
@PRE
<1,1> cap();
<3,3> cap();
<5,5> cap();
@RULES
# Ex: B.B.A.
_degreeInMajor <- B [s] \. [s] B [s] \. [s] A [s] \. [s] @@
# Ex: M.B.A.
_degreeInMajor <- M [s] \. [s] B [s] \. [s] A [s] \. [s] @@
# Ex: M.S.W.
_degreeInMajor <- M [s] \. [s] S [s] \. [s] W [s] \. [s] @@
@PRE
<1,1> cap();
<3,3> cap();
@RULES
# Ex: Juris\_Doctor
_degreeInMajor <- Juris [s] _xWHITE [star s] Doctor [s] @@
@PRE
<1,1> cap();
@RULES
# Ex: BSCS
_degreeInMajor <- BSCS [s] @@
# Ex: BSEE
_degreeInMajor <- BSEE [s] @@
# Ex: MSEE
_degreeInMajor <- MSEE [s] @@
# Ex: MSCS
_degreeInMajor <- MSCS [s] @@
# Ex: BBA
_degreeInMajor <- BBA [s] @@
# Ex: MBA
_degreeInMajor <- MBA [s] @@
# Ex: BSW
_degreeInMajor <- BSW [s] @@
# Ex: MSW
_degreeInMajor <- MSW [s] @@
|
@NODES _ROOT
@POST
excise(1,6);
noop();
@RULES
_xNIL <-
Report ### (1)
_xWHITE ### (2)
approved ### (3)
_xWHITE ### (4)
on ### (5)
_xWILD [one matches=(\r \n)] ### (6)
@@
@POST
excise(1,6);
noop();
@RULES
_xNIL <-
NationalRad ### (1)
_xWHITE ### (2)
\| ### (3)
_xWILD ### (4)
com ### (5)
_xWILD [one matches=(\r \n)] ### (6)
@@
@POST
excise(1,5);
noop();
@RULES
_xNIL <-
Page ### (1)
_xWILD ### (2)
of ### (3)
_xWILD ### (4)
_xWILD [one matches=(\r \n)] ### (5)
@@
@POST
excise(1,6);
noop();
@RULES
_xNIL <-
_xPUNCT ### (1)
NationalRad ### (2)
_xWHITE ### (3)
Neuroradiologist ### (4)
_xPUNCT ### (5)
_xWILD [one matches=(\r \n)] ### (6)
@@
@POST
excise(1,6);
noop();
@RULES
_xNIL <-
Board ### (1)
_xWHITE ### (2)
Certified ### (3)
_xWHITE ### (4)
Radiologist ### (5)
_xWILD [one matches=(\r \n)] ### (6)
@@
@POST
excise(1,6);
noop();
@RULES
_xNIL <-
THIS ### (1)
_xBLANK ### (2)
REPORT ### (3)
_xWILD ### (4)
SIGNED ### (5)
_xEND ### (6)
@@
|
@NODES _LINE
@POST
noop()
@RULES
# ex. University of Miami(,) Orlando
_xNIL <-
_CompleteSchoolName [s]
_xWILD [s opt matches = (\, \: \; \-)]
_xWILD [s star matches = ( _xWHITE _whtSEP )]
_CityName [tree layer = ( _SchoolLocation )] @@
# ex. UNiversity of Pittsburg - Miami
_xNIL <-
_CompleteSchoolName [s]
_xWHITE [s ]
_xWILD [s opt matches = ( \-)]
_xWHITE [s]
_CityName [tree layer = ( _SchoolLocation )] @@
# ex. University of Miami(,) at Orlando
_xNIL <-
_CompleteSchoolName [s]
_xWILD [s opt matches = (\, \: \; \-)]
at [s]
_xWHITE [s]
_CityName [tree layer = ( _SchoolLocation )] @@
|
@NODES _LINE
@RULES
_xNIL <- _xNIL @@
#_company <-
# _xWILD [s one match=(_company _companyPhrase _companyModroot)]
# \, [s opt]
# _xWHITE [s]
# _companyRoot [s] @@
#@RULES
#_company <-
# _xALPHA [s]
# \, [s opt]
# _xWHITE [s]
# _companyRoot [s] @@
|
@PATH _ROOT _attr _type _LINE
@POST
X("type",2) = N("word",1);
@RULES
_xNIL <-
_string
_xEND
@@
|
@NODES _ROOT
@RULES
_brackets <-
\[ ### (1)
_xWILD [fail=(\])] ### (2)
\] ### (3)
@@
|
@NODES _LINE
@RULES
_countryName <-
_xWILD [s one match=(_countryWord _countryPhrase)]
@@
|
@PATH _ROOT _LINE _language
@POST
X("abbrev",3) = N("$text",2);
X("con",2) = makeconcept(G("languages"),N("$text",2));
single();
@RULES
_abbrev <-
\[ ### (1)
_xALPHA ### (2)
\] ### (3)
@@
|
# Reduces a node labeled _noun to an _np
@RULES
_np [base] <- _noun @@ |
##################################################
# 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
##################################################
@CODE
G("word") = addword("January");
addnumval(G("word"),"Month",1);
G("word") = addword("Jan");
addnumval(G("word"),"Month",1);
G("word") = addword("February");
addnumval(G("word"),"Month",2);
G("word") = addword("Feb");
addnumval(G("word"),"Month",2);
G("word") = addword("March");
addnumval(G("word"),"Month",3);
G("word") = addword("Mar");
addnumval(G("word"),"Month",3);
G("word") = addword("April");
addnumval(G("word"),"Month",4);
G("word") = addword("Apr");
addnumval(G("word"),"Month",4);
G("word") = addword("May");
addnumval(G("word"),"Month",5);
G("word") = addword("June");
addnumval(G("word"),"Month",6);
G("word") = addword("Ju");
addnumval(G("word"),"Month",6);
G("word") = addword("July");
addnumval(G("word"),"Month",7);
G("word") = addword("Jy");
addnumval(G("word"),"Month",7);
G("word") = addword("August");
addnumval(G("word"),"Month",8);
G("word") = addword("Aug");
addnumval(G("word"),"Month",8);
G("word") = addword("September");
addnumval(G("word"),"Month",9);
G("word") = addword("Sept");
addnumval(G("word"),"Month",9);
G("word") = addword("Sep");
addnumval(G("word"),"Month",9);
G("word") = addword("October");
addnumval(G("word"),"Month",10);
G("word") = addword("Oct");
addnumval(G("word"),"Month",10);
G("word") = addword("November");
addnumval(G("word"),"Month",11);
G("word") = addword("Nov");
addnumval(G("word"),"Month",11);
G("word") = addword("December");
addnumval(G("word"),"Month",12);
G("word") = addword("Dec");
addnumval(G("word"),"Month",12);
@@CODE
@NODES _ROOT
@POST
G("stem") = strtolower(N("$text",5));
if (strequal(strtolower(G("stem")),"hundred")) {
G("Numeral Value") = 100;
}
else if (strequal(strtolower(G("stem")),"thousand")) {
G("Numeral Value") = 1000;
}
else if (strequal(strtolower(G("stem")),"million")) {
G("Numeral Value") = 1000000;
}
else if (strequal(strtolower(G("stem")),"billion")) {
G("Numeral Value") = 1000000000;
}
else if (strequal(strtolower(G("stem")),"trillion")) {
G("Numeral Value") = 1000000000000;
}
S("Numeral Value") = num(N("$text",1)) * G("Numeral Value");
single();
@@POST
@RULES
_cardinalNumeral <-
_xNUM [one] ### (1)
\. [opt] ### (2)
_xNUM [opt] ### (3)
_xWILD [star match=(_xWHITE "_whiteSpace")] ### (4)
_xWILD [one match=("hundred" "thousand" "million" "billion" "trillion")] ### (5)
@@
@@RULES
#######################
# Ordinal with integer#
#######################
@POST
G("numeralT") = N("$text",1);
S("Numeral Value") = num(G("numeralT"));
single();
@@POST
@RULES
_ordinalNumeral <-
_xNUM [s one] ### (1)
_xWILD [s min=1 max=1 match=("st" "nd" "rd" "th")] ### (2)
@@
@@RULES
#####################
# One word ordinals #
#####################
@POST
G("stem") = N("$text",1);
if (strequal(strtolower(G("stem")),"first")) {
S("Numeral Value") = 1;
}
else if (strequal(strtolower(G("stem")),"second")) {
S("Numeral Value") = 2;
}
else if (strequal(strtolower(G("stem")),"third")) {
S("Numeral Value") = 3;
}
else if (strequal(strtolower(G("stem")),"fourth")) {
S("Numeral Value") = 4;
}
else if (strequal(strtolower(G("stem")),"fifth")) {
S("Numeral Value") = 5;
}
else if (strequal(strtolower(G("stem")),"sixth")) {
S("Numeral Value") = 6;
}
else if (strequal(strtolower(G("stem")),"seventh")) {
S("Numeral Value") = 7;
}
else if (strequal(strtolower(G("stem")),"eighth")) {
S("Numeral Value") = 8;
}
else if (strequal(strtolower(G("stem")),"ninth")) {
S("Numeral Value") = 9;
}
else if (strequal(strtolower(G("stem")),"tenth")) {
S("Numeral Value") = 10;
}
else if (strequal(strtolower(G("stem")),"eleventh")) {
S("Numeral Value") = 11;
}
else if (strequal(strtolower(G("stem")),"twelfth")) {
S("Numeral Value") = 12;
}
else if (strequal(strtolower(G("stem")),"thirteenth")) {
S("Numeral Value") = 13;
}
else if (strequal(strtolower(G("stem")),"fourteenth")) {
S("Numeral Value") = 14;
}
else if (strequal(strtolower(G("stem")),"fifteenth")) {
S("Numeral Value") = 15;
}
else if (strequal(strtolower(G("stem")),"sixteenth")) {
S("Numeral Value") = 16;
}
else if (strequal(strtolower(G("stem")),"seventeenth")) {
S("Numeral Value") = 17;
}
else if (strequal(strtolower(G("stem")),"eighteenth")) {
S("Numeral Value") = 18;
}
else if (strequal(strtolower(G("stem")),"nineteenth")) {
S("Numeral Value") = 19;
}
else if (strequal(strtolower(G("stem")),"twentieth")) {
S("Numeral Value") = 20;
}
else if (strequal(strtolower(G("stem")),"thirtieth")) {
S("Numeral Value") = 30;
}
else if (strequal(strtolower(G("stem")),"fortieth")) {
S("Numeral Value") = 40;
}
else if (strequal(strtolower(G("stem")),"fiftieth")) {
S("Numeral Value") = 50;
}
else if (strequal(strtolower(G("stem")),"sixtieth")) {
S("Numeral Value") = 60;
}
else if (strequal(strtolower(G("stem")),"seventieth")) {
S("Numeral Value") = 70;
}
else if (strequal(strtolower(G("stem")),"eightieth")) {
S("Numeral Value") = 80;
}
else if (strequal(strtolower(G("stem")),"ninetieth")) {
S("Numeral Value") = 90;
}
else if (strequal(strtolower(G("stem")),"hundredth")) {
S("Numeral Value") = 100;
}
else if (strequal(strtolower(G("stem")),"thousandth")) {
S("Numeral Value") = 1000;
}
else if (strequal(strtolower(G("stem")),"millionth")) {
S("Numeral Value") = 1000000;
}
else if (strequal(strtolower(G("stem")),"billionth")) {
S("Numeral Value") = 1000000000;
}
else if (strequal(strtolower(G("stem")),"trillionth")) {
S("Numeral Value") = 1000000000000;
}
single();
@@POST
@RULES
_ordinalNumeral <-
_xWILD [s min=1 max=1 match=("first" "second" "third" "fourth" "fifth" "sixth" "seventh" "eighth" "ninth" "tenth" "eleventh" "twelfth" "thirteenth" "fourteenth" "fifteenth" "sixteenth" "seventeenth" "eighteenth" "nineteenth" "twentieth" "thirtieth" "fortieth" "fiftieth" "sixtieth" "seventieth" "eightieth" "ninetieth" "hundredth" "thousandth" "millionth" "billionth" "trillionth")] ### (1)
@@
@@RULES
#####################
# One word cardinals #
#####################
@POST
G("stem") = N("$text",1);
if (strequal(strtolower(G("stem")),"one")) {
S("Numeral Value") = 1;
}
else if (strequal(strtolower(G("stem")),"two")) {
S("Numeral Value") = 2;
}
else if (strequal(strtolower(G("stem")),"three")) {
S("Numeral Value") = 3;
}
else if (strequal(strtolower(G("stem")),"four")) {
S("Numeral Value") = 4;
}
else if (strequal(strtolower(G("stem")),"five")) {
S("Numeral Value") = 5;
}
else if (strequal(strtolower(G("stem")),"six")) {
S("Numeral Value") = 6;
}
else if (strequal(strtolower(G("stem")),"seven")) {
S("Numeral Value") = 7;
}
else if (strequal(strtolower(G("stem")),"eight")) {
S("Numeral Value") = 8;
}
else if (strequal(strtolower(G("stem")),"nine")) {
S("Numeral Value") = 9;
}
else if (strequal(strtolower(G("stem")),"ten")) {
S("Numeral Value") = 10;
}
else if (strequal(strtolower(G("stem")),"eleven")) {
S("Numeral Value") = 11;
}
else if (strequal(strtolower(G("stem")),"twelve")) {
S("Numeral Value") = 12;
}
else if (strequal(strtolower(G("stem")),"thirteen")) {
S("Numeral Value") = 13;
}
else if (strequal(strtolower(G("stem")),"fourteen")) {
S("Numeral Value") = 14;
}
else if (strequal(strtolower(G("stem")),"fifteen")) {
S("Numeral Value") = 15;
}
else if (strequal(strtolower(G("stem")),"sixteen")) {
S("Numeral Value") = 16;
}
else if (strequal(strtolower(G("stem")),"seventeen")) {
S("Numeral Value") = 17;
}
else if (strequal(strtolower(G("stem")),"eighteen")) {
S("Numeral Value") = 18;
}
else if (strequal(strtolower(G("stem")),"nineteen")) {
S("Numeral Value") = 19;
}
else if (strequal(strtolower(G("stem")),"twenty")) {
S("Numeral Value") = 20;
}
else if (strequal(strtolower(G("stem")),"thirty")) {
S("Numeral Value") = 30;
}
else if (strequal(strtolower(G("stem")),"forty")) {
S("Numeral Value") = 40;
}
else if (strequal(strtolower(G("stem")),"fifty")) {
S("Numeral Value") = 50;
}
else if (strequal(strtolower(G("stem")),"sixty")) {
S("Numeral Value") = 60;
}
else if (strequal(strtolower(G("stem")),"seventy")) {
S("Numeral Value") = 70;
}
else if (strequal(strtolower(G("stem")),"eighty")) {
S("Numeral Value") = 80;
}
else if (strequal(strtolower(G("stem")),"ninety")) {
S("Numeral Value") = 90;
}
else if (strequal(strtolower(G("stem")),"hundred")) {
S("Numeral Value") = 100;
}
else if (strequal(strtolower(G("stem")),"thousand")) {
S("Numeral Value") = 1000;
}
else if (strequal(strtolower(G("stem")),"million")) {
S("Numeral Value") = 1000000;
}
else if (strequal(strtolower(G("stem")),"billion")) {
S("Numeral Value") = 1000000000;
}
else if (strequal(strtolower(G("stem")),"trillion")) {
S("Numeral Value") = 1000000000000;
}
single();
@@POST
@RULES
_cardinalNumeral <-
_xWILD [s min=1 max=1 match=("one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" "seventeen" "eighteen" "nineteen" "twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety" "hundred" "thousand" "million" "billion" "trillion")] ### (1)
@@
@@RULES
|
@NODES _LINE _humanNameCandidate
# Zap all matched nodes in parse tree.
@POST
excise(1,1);
@RULES
# Retaining these for now. #
_xNIL <- _xWILD [one match=(_whtINDENT _whtSEP)] @@
|
@CODE
L("hello") = 0;
if (G("verbose"))
"wsd.txt" << "\n" << "ANAPHORA100 PASS" << "\n";
@@CODE
@NODES _sent
# that
@CHECK
if (N("pattern",2) != "n")
fail();
@POST
L("np") = N("np",2);
if (N("pattern",4) == "vn"
|| N("pattern",4) == "v"
)
{
# Resolve using earlier np.
N("np1 remote",4) = L("np");
}
if (N("pattern",6) == "vn"
|| N("pattern",6) == "v"
)
{
# Resolve using earlier np.
N("np1 remote",6) = L("np");
}
@RULES
_xNIL <-
_xSTART
_clause
_xWILD [s one match=(which that)]
_clause [lookahead]
_prep
_clause
@@
# that
@CHECK
if (N("pattern",2) != "n")
fail();
@POST
L("np") = N("np",2);
if (N("pattern",4) == "vn"
|| N("pattern",4) == "v"
)
{
# Resolve using earlier np.
N("np1 remote",4) = L("np");
}
@RULES
_xNIL <-
_xSTART
_clause
_xWILD [s one lookahead match=(which that)]
_clause
@@
@CHECK
L("pat3") = N("pattern",3);
if (!L("pat3"))
fail();
if (strpiece(L("pat3"),0,0) != "v")
fail();
L("pat2") = N("pattern",2);
if (!L("pat2"))
fail();
if (strpiece(L("pat2"),0,0) != "n")
fail();
if (vconjq(N(3),"-en"))
fail();
@POST
# Distribute np to second clause.
L("np") = N("np1",2);
if (!L("np"))
L("np") = N("np",2);
if (L("np"))
{
N("np1 remote",3) = L("np");
# Distribute to 3rd clause.
if (N("pattern",5))
{
if (strpiece(N("pattern",5),0,0) == "v")
N("np1 remote",5) = L("np");
}
}
@RULES
_xNIL <-
_xSTART
_clause
_clause [lookahead]
_xWILD [s one match=(while when _conj)]
_clause
@@
# passive passive.
# X was processed by Y connected to Z.
# Y is the resolver.
@CHECK
if (N("voice",1) != "passive"
|| N("voice",2) != "passive")
fail();
if (!N("pattern",2))
fail(); # Flag this to debug file...
if (strpiece(N("pattern",2),0,0) != "v")
fail();
# Get last np in clause.
if (!N("last np",1))
fail();
@POST
N("np1 remote",2) = N("last np",1);
@RULES
_xNIL <-
_clause
_clause [lookahead]
@@
@CHECK
L("pat2") = N("pattern",2);
if (!L("pat2"))
fail();
if (strpiece(L("pat2"),0,0) != "v")
fail();
L("pat1") = N("pattern",1);
if (!L("pat1"))
fail();
if (strpiece(L("pat1"),0,0) != "n")
fail();
if (vconjq(N(2),"-en"))
fail();
@POST
# Distribute np to second clause.
L("np") = N("np1",1);
if (!L("np"))
L("np") = N("np",1);
if (L("np"))
{
N("np1 remote",2) = L("np");
}
N("id",2) = "anaph100 c-c";
@RULES
_xNIL <-
_clause
_clause [lookahead]
@@
|
@CODE
prlit("output.xml", "<JobCandidateContact>\n");
@@CODE
@MULTI _contactZone # 09/04/99 AM.
@POST
prxtree("output.xml", "Title: ", 1, "_prefixName", "\n");
prxtree("output.xml", "<Name>\n<First>", 1, "_firstName", "</First>\n");
prxtree("output.xml", "Middle Name: ", 1, "_middleName", "\n");
prxtree("output.xml", "<Last>", 1, "_lastName", "</Last>\n</Name>\n");
prxtree("output.xml", "Suffix Name: ", 1, "_suffixName", "\n");
@RULES
_xNIL <- _humanName @@
@POST
prxtree("output.xml", "<Email>", 1, "_email", "</Email>\n");
@RULES
_xNIL <- _email @@
@POST
prxtree("output.xml", "<Website>", 1, "_url", "</Website>\n");
@RULES
_xNIL <- _url @@
@POST
prlit("output.xml", "<Address>\n");
prlit("output.xml", "<AddressLine>\n");
prxtree("output.xml", "PO Box ", 1, "_poBoxNumber", " ");
prxtree("output.xml", " ", 1, "_streetNumber", " ");
prxtree("output.xml", " ", 1, "_direction", " ");
prxtree("output.xml", " ", 1, "_streetName", " ");
prxtree("output.xml", " ", 1, "_road", " ");
prxtree("output.xml", " ", 1, "_unit", " ");
prxtree("output.xml", " ", 1, "_room", " ");
prlit("output.xml", "\n</AddressLine>\n");
prlit("output.xml", "</Address>\n");
@RULES
_xNIL <- _addressLine @@
@POST
prlit("output.xml", "<Address>\n");
prlit("output.xml", "<AddressLine>\n");
prxtree("output.xml", " ", 1, "_unit", " ");
prxtree("output.xml", " ", 1, "_room", " ");
prlit("output.xml", "\n</AddressLine>\n");
prlit("output.xml", "\n</Address>\n");
@RULES
_xNIL <- _unitRoom @@
@POST
prlit("output.xml", "<Address>\n");
prxtree("output.xml", "<City> ", 1, "_cityName", " </City>\n");
prxtree("output.xml", "<State> ", 1, "_stateName", " </State>\n");
prxtree("output.xml", "<Province> ", 1, "_province", " </Province>\n");
prxtree("output.xml", "<PostalCode> ", 1, "_zipCode", " </PostalCode>\n");
prxtree("output.xml", " ", 1, "_zipSuffix", "\n");
prxtree("output.xml", "<Country>", 1, "_country", " </Country>\n");
prlit("output.xml", "</Address>\n");
@RULES
_xNIL <- _cityStateZip @@
@CHECK
if (G("cityStateZip")) fail();
@POST
prlit("output.xml", "<Address>\n");
prxtree("output.xml", "<City> ", 1, "_cityName", " </City>\n");
prxtree("output.xml", "<State> ", 1, "_stateName", " </State>\n");
prxtree("output.xml", "<Province> ", 1, "_province", "</Province>\n");
prlit("output.xml", "</Address>\n");
@RULES
_xNIL <- _cityState @@
# This XML schema distinguishes three types of phone numbers:
# Voice, Fax and Pager. Here's the voice
@POST
prlit("output.xml", "<PhoneNumbers>");
prlit("output.xml", "\n<Voice>");
prxtree("output.xml", "\n<IntlCode> ", 1, "_countryCode", " </IntlCode>");
prxtree("output.xml", "\n<AreaCode> ", 1, "_areaCode", " </AreaCode>");
prlit("output.xml", "\n<TelNumber> ");
prtree("output.xml", 1, "_prefix");
prtree("output.xml", 1, "_suffix");
prlit("output.xml", " </TelNumber>");
prlit("output.xml", "\n</Voice>");
prlit("output.xml", "\n</PhoneNumbers>\n");
@RULES
#_xNIL <- _phoneNumber @@
_xNIL <- _xWILD [one matches=( _phoneNumber
_phoneHomePhrase _phoneWorkPhrase _phoneCellPhrase)]@@
# Here's the fax
@POST
prlit("output.xml", "<PhoneNumbers>");
prlit("output.xml", "\n<Fax>");
prxtree("output.xml", "\n<IntlCode> ", 1, "_countryCode", " </IntlCode>");
prxtree("output.xml", "\n<AreaCode> ", 1, "_areaCode", " </AreaCode>");
prlit("output.xml", "\n<TelNumber> ");
prtree("output.xml", 1, "_prefix");
prtree("output.xml", 1, "_suffix");
prlit("output.xml", " </TelNumber>");
prlit("output.xml", "\n</Fax>");
prlit("output.xml", "\n</PhoneNumbers>\n");
@RULES
#_xNIL <- _phoneNumber @@
_xNIL <- _xWILD [one matches=(
_phoneHomeFaxPhrase
_phoneFaxPhrase)]@@
# pager phone number
@POST
prlit("output.xml", "<PhoneNumbers>");
prlit("output.xml", "\n<Pager>");
prxtree("output.xml", "\n<IntlCode> ", 1, "_countryCode", " </IntlCode>");
prxtree("output.xml", "\n<AreaCode> ", 1, "_areaCode", " </AreaCode>");
prlit("output.xml", "\n<TelNumber> ");
prtree("output.xml", 1, "_prefix");
prtree("output.xml", 1, "_suffix");
prlit("output.xml", " </TelNumber>");
prlit("output.xml", "\n</Pager>");
prlit("output.xml", "\n</PhoneNumbers>\n");
@RULES
_xNIL <- _xWILD [one matches=( _phonePagerPhrase )]@@
|
# @NODES _ROOT
@PATH _ROOT
@CHECK
if (
#Nlt(3, "nblobs", 6)
#Nlt(5, "nblobs", 6)
(N("nblobs",3) < 6) && (N("nblobs",5) < 6)
)
succeed();
fail();
@POST
noop();
@RULES
_xNIL <- _xSTART
_xWILD [s star match=( _BLANKLINE _horizRule)]
_xANY
_xWILD [s star match=( _BLANKLINE _horizRule)]
_xANY
@@
@POST
noop();
@RULES
_xNIL <- _xSTART
_xWILD [s star match=(_BLANKLINE _horizRule)]
_xANY
@@
# Skip resume of constructs, and any lines with unknown words.
@CHECK
if (
N("html turd", 2) || N("resumeOf", 2)
|| N("nunknowns", 2)
)
succeed();
fail();
@POST
noop();
@RULES
_xNIL <-
_xWILD [s star match=(_BLANKLINE _horizRule)]
_xANY
@@
# Skip known resume headers. #
@CHECK
if (!N("ResumeByItselfLine", 2)) fail();
@POST
noop();
@RULES
_xNIL <-
_xWILD [s star match=(_BLANKLINE _horizRule)]
_xANY # E.g, resume of
_xWILD [s star match=(_BLANKLINE _horizRule)]
_xANY # E.g., John Q. Smith
@@
# Basically moved this from previous pass.
# Line based on having blank line before and after.
#@CHECK
# Nlt(2, "nblobs", 5)
# Neq(2, "addressParts", 0)
# Nlt(2, "walpha", 5)
# Neq(2, "wnum", 0)
#@RULES
#_otherBoundary <-
# _xWILD [s plus match=(_BLANKLINE _horizRule)] # >=1 above.
# _xWILD [s one fails=(_horizRule _BLANKLINE) trig]
# _xWILD [s plus match=(_BLANKLINE _horizRule)] # >=1 below.
# @@
# this section removed 01.28.
# incorrect zoning on felbab, e.g. education
# where it inserted 'other bounday' on a blank line
# Should have all alphas capitalized.
#@CHECK
# Neq(2, "addressParts", 0)
# Nlt(2, "walpha", 5) # Header. Little text.
# Neq(2, "wnum", 0) # No numbers on this line.
# Ngt(4, "walpha", 6) # First line of section. Lots of text.
#@POST
# singler(1,3) # All but first line of section.
#@RULES
#_otherBoundary <-
# _xWILD [s plus match=(_BLANKLINE _horizRule)] # One thing above.
# _LINE [s] # Candidate header line.
# _xWILD [s star match=(_BLANKLINE _horizRule)]
# _LINE [s] # Some alphabetic line.
# @@
|
# Switch places of first two children of parse tree root (assumes they
exist).
L("n1") = pndown(pnroot());
L("n2") = pnnext(L("n1"));
pnmove(L("n1"),L("n2"),1); |
@CODE
if (!G("pretagged"))
exitpass();
@@CODE
@NODES _ROOT
@POST
splice(1,1);
@RULES
_xNIL <-
_pos
@@
|
###############################################
# FILE: DATE_PATTERNS.pat #
# SUBJ: Recognize date expressions with year #
# AUTH: Paul Deane #
# CREATED: 26/Feb/01
# DATE OF THIS VERSION: 31/Aug/01 #
# Copyright
###############################################
@NODES _ROOT
@CHECK
S("N1") = N("Numeral Value",3) ;
if (S("N1")) {
if ( S("N1") < 1 && S("N1") > 31) {
fail();
}
}
if ( strlength(N("$text",12)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",3);
S("Year Value") = num(N("$text",12));
G("WordStr") = N("$text",9);
S("MaxArrayPos") = 0;
G("Word") = dictfindword(G("WordStr"));
S("Month Value") = numval(G("Word"),"Month");
single();
@@POST
@RULES
_dateExpr [base] <-
the [s opt]### (1)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2)
_xWILD [s one matches=("_ordinalNumeral")] ### (3)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4)
_xWILD [s opt matches=("day" "days")] ### (5)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6)
of [s opt] ### (7)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (8)
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt] ### (10)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (11)
_xNUM [s min=1 max=1] ### (12)
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",3)[0] ;
if (S("N1")) {
if ( S("N1") < 1 && S("N1") > 31) {
fail();
}
}
if ( strlength(N("$text",12)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",3);
S("Year Value") = num(N("$text",12));
G("WordStr") = N("$text",9);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = N("MaxArrayPos",3);
single();
@@POST
@RULES
_dateExpr [base] <-
the [s opt]### (1)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (2)
_xWILD [s one matches=("_ordinalList" "_ordinalSequence")] ### (3)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (4)
_xWILD [s opt matches=("day" "days")] ### (5)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (6)
of [s opt] ### (7)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (8)
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt] ### (10)
_xWILD [s opt match=(_xWHITE "_whiteSpace")] ### (11)
_xNUM [s min=1 max=1] ### (12)
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",3);
if (S("N1")) {
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",3);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",12);
G("WordStr") = N("$text",9);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
the [s opt]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_ordinalNumeral")]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s opt matches=("day" "days")] ### (5)
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
of [s opt]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s min=1 max=1 match=("January" "Jan" "February" "Feb" "March" "April" "Apr" "May" "June" "July" "Jy" "Jul" "August" "Aug" "September" "Sept" "Sep" "October" "Oct" "November" "Nov" "December" "Dec")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",3)[0];
if (S("N1")) {
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",3);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",12);
G("WordStr") = N("$text",9);
S("MaxArrayPos") = N("MaxArrayPos",3);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
single();
@@POST
@RULES
_dateExpr [base] <-
the [s opt]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_ordinalList" "_ordinalSequence")]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s opt matches=("day" "days")] ### (5)
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
of [s opt]
_whiteSpace [s opt]
_xWILD [s min=1 max=1 match=("January" "Jan" "February" "Feb" "March" "April" "Apr" "May" "June" "July" "Jy" "Jul" "August" "Aug" "September" "Sept" "Sep" "October" "Oct" "November" "Nov" "December" "Dec")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",5);
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",8)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",5);
S("Year Value") = num(N("$text",8));
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
the [s opt]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_ordinalNumeral")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",5)[0];
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",8)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",5);
S("Year Value") = num(N("$text",8));
G("WordStr") = N("$text",1);
S("MaxArrayPos") = N("MaxArrayPos",5);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
the [s opt]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_ordinalList" "_ordinalSequence")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",5);
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",5);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",8);
G("WordStr") = N("$text",1);
G("Word") = 0;
G("Word") = dictfindword(G("WordStr"));
if (G("word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan" "February" "Feb" "March" "April" "Apr" "May" "June" "Ju" "July" "Jy" "Jul" "August" "Aug" "September" "Sept" "Sep" "October" "Oct" "November" "Nov" "December" "Dec")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
the [s opt]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_ordinalNumeral")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",5)[0];
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",5);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",8);
G("WordStr") = N("$text",1);
G("Word") = 0;
S("MaxArrayPos") = N("MaxArrayPos",5);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan" "February" "Feb" "March" "April" "Apr" "May" "June" "Ju" "July" "Jy" "Jul" "August" "Aug" "September" "Sept" "Sep" "October" "Oct" "November" "Nov" "December" "Dec")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
the [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_ordinalList" "_ordinalSequence")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",1);
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",6)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",1);
S("Year Value") = num(N("$text",6));
G("WordStr") = N("$text",3);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s one matches=("_cardinalNumeral")]
_xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2)
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt] ### (4)
_xWILD [s one match=(_xWHITE "_whiteSpace")] ### (5)
_xNUM [s one] ### (6)
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",1)[0];
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",6)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",1);
S("Year Value") = num(N("$text",6));
G("WordStr") = N("$text",3);
G("Word") = dictfindword(G("WordStr"));
S("MaxArrayPos") = N("MaxArrayPos",1);
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s one matches=("_cardinalList" "_cardinalSequence")]
_xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2)
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt] ### (4)
_xWILD [s one match=(_xWHITE "_whiteSpace")] ### (5)
_xNUM [s one] ### (6)
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",1);
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",1);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",6);
G("WordStr") = N("$text",3);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
G("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s one matches=("_cardinalNumeral")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",1)[0];
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",1);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",6);
G("WordStr") = N("$text",3);
S("MaxArrayPos") = N("MaxArrayPos",1);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
G("Month Value") = numval(G("Word"),"Month");
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s one matches=("_cardinalList" "_cardinalSequence")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@CHECK
S("N1") = num(N("$text",1));
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",6)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value") = num(N("$text",1));
S("Year Value") = num(N("$text",6));
G("WordStr") = N("$text",3);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xNUM [s one] ### (1)
_xWILD [s one match=(_xWHITE "_whiteSpace")] ### (2)
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt] ### (4)
_xWILD [s one match=(_xWHITE "_whiteSpace")] ### (5)
_xNUM [s one] ### (6)
@@
@@RULES
@CHECK
S("N1") = num(N("$text",1));
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
@@CHECK
@POST
S("Date Value") = num(N("$text",1));
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",6);
G("WordStr") = N("$text",3);
G("Word") = dictfindword(G("WordStr"));
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xNUM [s one]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@CHECK
S("N1") = N("Numeral Value",3);
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",6)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",3);
S("Year Value") = num(N("$text",6));
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr <-
_xWILD [s one match=("January" "Jan" "February" "Feb" "March" "April" "Apr" "May" "June" "July" "Jy" "Jul" "August" "Aug" "September" "Sept" "Sep" "October" "Oct" "November" "Nov" "December" "Dec")]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_cardinalNumeral")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
@@
@@RULES
@CHECK
S("N1") = num(N("$text",3));
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",6)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",3);
S("Year Value") = num(N("$text",6));
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
S("MaxArrayPos") = N("MaxArrayPos",3);
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr <-
_xWILD [s one match=("January" "Jan" "February" "Feb" "March" "April" "Apr" "May" "June" "July" "Jy" "Jul" "August" "Aug" "September" "Sept" "Sep" "October" "Oct" "November" "Nov" "December" "Dec")]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_cardinalList" "_cardinalSequence")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
@@
@@RULES
@CHECK
S("N0") = N("Numeral Value",3);
S("N1") = S("N0");
if ( S("N1") < 1 )
fail();
if ( S("N1") > 31) {
fail();
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",3);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",6);
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
if (G("Word")) {
S("Month Value") = numval(G("Word"),"Month");
}
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_cardinalNumeral")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [ s one]
@@
@@RULES
@CHECK
S("N0") = N("$text",3);
S("N1") = S("N0");
if ( S("N1") < 1 )
fail();
if ( S("N1") > 31) {
fail();
}
@@CHECK
@POST
S("Date Value List") = N("Numeral Value",3);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",6);
G("WordStr") = N("$text",1);
S("MaxArrayPos") = N("MaxArrayPos",3);
G("Word") = dictfindword(G("WordStr"));
if (G("Word")) {
S("Month Value") = numval(G("Word"),"Month");
}
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
_xWILD [s opt match=(_xWHITE "_whiteSpace")]
_xWILD [s one matches=("_cardinalList" "_cardinalSequence")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [ s one]
@@
@@RULES
@CHECK
S("N1") = num(N("$text",3));
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
if ( strlength(N("$text",6)) != 4 ) {
fail();
}
@@CHECK
@POST
S("Date Value") = num(N("$text",3));
S("Year Value") = num(N("$text",6));
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
@@
@@RULES
@CHECK
if (N("$text",4)) {
if ( strlength(N("$text",4)) != 4 ) {
fail();
}
}
@@CHECK
@POST
S("Date Value") = 0;
S("Year Value") = num(N("$text",4));
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
if (G("Word"))
S("Month Value") = numval(G("Word"),"Month");
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
@@
@@RULES
@CHECK
if (N("$text",3)) {
S("N1") = num(N("$text",3));
if ( S("N1") < 1 || S("N1") > 31) {
fail();
}
}
@@CHECK
@POST
S("Date Value") = N("Numeral Value",3);
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",6);
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
G("attrname") = "Month";
if (G("Word"))
S("Month Value") = numval(G("Word"),G("attrname"));
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_xNUM [s one]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
@POST
S("Date Value") = 0;
S("Year Value") = 0;
S("YearInCentury") = N("YearInCentury",4);
G("WordStr") = N("$text",1);
G("Word") = dictfindword(G("WordStr"));
G("attrname") = "Month";
S("Month Value") = numval(G("Word"),G("attrname"));
S("MaxArrayPos") = 0;
single();
@@POST
@RULES
_dateExpr [base] <-
_xWILD [s min=1 max=1 match=("January" "Jan." "Jan" "February" "Feb." "Feb" "March" "April" "Apr." "Apr" "May" "June" "Ju." "July" "Jy." "Jy" "Jul." "Jul" "August" "Aug." "Aug" "September" "Sept." "Sept" "Sep." "Sep" "October" "Oct." "Oct" "November" "Nov." "Nov" "December" "Dec." "Dec")]
\, [s opt]
_xWILD [s one match=(_xWHITE "_whiteSpace")]
_yearAbbr [s one]
@@
@@RULES
|
@NODES _ROOT
@POST
splice(1,1);
@RULES
_xNIL <-
_enum
@@
|
@NODES _ROOT
@RULES
_textEnd <-
\< ### (1)
\/ ### (2)
text ### (3)
\> ### (4)
@@
@RULES
_textStart <-
\< ### (1)
text ### (2)
_xWILD [fail=(\>)] ### (3)
\> ### (4)
@@
@POST
X("word",1) = N("$text",4);
single();
@RULES
_word <-
\< ### (1)
title ### (2)
\> ### (3)
_xALPHA ### (4)
\< ### (5)
\/ ### (6)
title ### (7)
\> ### (8)
@@ |
@CODE
# Bitwise tests
# L("or") = 8 | 4;
# "test.txt" << "8 | 4 = 12 [" << L("or") << "]\n";
# L("and") = 8 & 12;
# "test.txt" << "8 & 12 = 4 [" << L("and") << "]\n";
# L("rshift") = 8 >> 2;
# "test.txt" << "8 >> 2 = 2 [" << L("rshift") << "]\n";
# L("lshift") = 8 << 2;
# "test.txt" << "8 << 2 = 32 [" << L("lshift") << "]\n";
"test.txt" << exp(4) << "\n";
@@CODE |
# Add str as string value to concept con's attribute called name.
addstrval(L("con"), L("name"), L("str")); |
@CODE
XMLOut(cbuf());
XMLOut("output.xml");
@@CODE |
@NODES _ROOT
@POST
S("header") = N("header", 1);
single();
@RULES
_headerZone <-
_zoneHeader ### (1)
_xWILD [fail=(_zoneHeader _xEND)] ### (2)
@@
|
@PATH _ROOT _paragraph _sentence
@POST
S("value") = N("value",1);
S("type") = N("$text",3);
single();
@RULES
_money <-
_money [s] ### (1)
in [s] ### (2)
_moneyType [s] ### (3)
@@
_money <-
_money [s] ### (1)
_det [s] ### (2)
share [s] ### (3)
@@
@POST
S("value") = N("value",4);
S("type") = N("$text",2);
single();
@RULES
_money <-
_det [s] ### (1)
total [s] ### (2)
_prep [s] ### (3)
_money [s] ### (4)
@@
@POST
S("value") = N("value",2);
S("type") = N("compare",1);
single();
@RULES
_money <-
_compare [s] ### (1)
_money [s] ### (2)
@@ |
@CODE
fileout( "edu.txt" );
@@CODE
# Traverse a line, looking for education parts.
# Keep an ordering counter for each line.
# NOTE: Because the edu parts may be scattered, the ordering may
# be approximate, but that's good enough for now.
# NOTE: If an edupart is already assigned, it's value gets
# overwritten. Could accumulate redundancy counters also, or
# could store multiple order values per variable.
# At least could flag some nonadjacent redundancy as a possible
# in-line segmentation point. (later.....)
# parts will be found in a more principled fashion. (Sometimes
# they are nested in each other).
# Implementing notion of FIRST part and LAST part on a line.
# Using ENUM VALUES as follows:
# 0-none, 1-major,2-minor,3-school,4-degree,5-grade,6-date.
@PATH _ROOT _educationZone _LINE
@POST
if (X("eduparts") == 0)
X("first edupart") = 2;
X("last edupart") = 2;
++X("eduparts");
X("Ominor") = X("eduparts");
# XXsetifzero( "first edupart", 2, "eduparts")
#Xset( "last edupart", 2)
#Xinc( "eduparts" )
#XsetX( "Ominor", "eduparts" )
# noop()
@RULES
_xNIL <- _minor [s] @@
@POST
if (X("eduparts") == 0)
X("first edupart") = 1;
X("last edupart") = 1;
++X("eduparts");
X("Omajor") = X("eduparts");
# XXsetifzero( "first edupart", 1, "eduparts")
# Xset( "last edupart", 1) # Last one seen is major.
# Xinc( "eduparts" )
# XsetX( "Omajor", "eduparts" ) # line(var1) = line(var2)
# noop() # document no reduction
@RULES
_xNIL <- _major [s] @@
@POST
if (X("eduparts") == 0)
X("first edupart") = 3;
X("last edupart") = 3;
++X("eduparts");
X("Oschool") = X("eduparts");
#XXsetifzero( "first edupart", 3, "eduparts")
#Xset( "last edupart", 3)
#Xinc( "eduparts" )
#XsetX ( "Oschool", "eduparts" )
# noop()
@RULES
_xNIL <- _CompleteSchoolName [s] @@
_xNIL <- _school [s] @@ # 12/15/99 AM.
@POST
if (X("eduparts") == 0)
X("first edupart") = 4;
X("last edupart") = 4;
++X("eduparts");
X("Odegree") = X("eduparts");
#XXsetifzero( "first edupart", 4, "eduparts")
#Xset( "last edupart", 4)
#Xinc( "eduparts" )
#XsetX ( "Odegree", "eduparts" )
# noop()
@RULES
_xNIL <- _degree [s] @@
@POST
if (X("eduparts") == 0)
X("first edupart") = 4; # First = DEGREE!
X("last edupart") = 1; # Last = MAJOR!
++X("eduparts");
X("Odegree") = X("eduparts");
X("Omajor") = X("eduparts"); # Record this also.
#XXsetifzero( "first edupart", 4, "eduparts")
#Xset( "last edupart", 4)
#Xinc( "eduparts" )
#XsetX ( "Odegree", "eduparts" )
# noop()
@RULES
_xNIL <- _degreeInMajor [s] @@
@POST
if (X("eduparts") == 0)
X("first edupart") = 5;
X("last edupart") = 5;
++X("eduparts");
X("Ograde") = X("eduparts");
#XXsetifzero( "first edupart", 5, "eduparts")
#Xset( "last edupart", 5)
#Xinc( "eduparts" )
#XsetX( "Ograde", "eduparts" )
# noop()
@RULES
_xNIL <- _Grade [s] @@
@POST
if (X("eduparts") == 0)
X("first edupart") = 6;
X("last edupart") = 6;
++X("eduparts");
X("Odate") = X("eduparts");
#XXsetifzero( "first edupart", 6, "eduparts")
#Xset( "last edupart", 6)
#Xinc( "eduparts" )
#XsetX( "Odate", "eduparts" )
# noop()
@RULES
_xNIL <- _xWILD [s one match=( _DateRange _SingleDate )] @@
|
@CODE
fileout("dumpy.txt"); # Must declare file.
prlit("dumpy.txt", "Globals:\n");
gdump("dumpy.txt");
prlit("dumpy.txt", "\n");
prlit("dumpy.txt", "DUMPING LINES\n");
prlit("dumpy.txt", "-------------\n");
prlit("dumpy.txt", "\n");
@@CODE
@NODES _ROOT
@POST
ndump("dumpy.txt",1);
prlit("dumpy.txt", "Globals:\n");
gdump("dumpy.txt");
prlit("dumpy.txt", "Root context:\n");
xdump("dumpy.txt", 1);
prlit("dumpy.txt", "Suggested node variables:\n");
sdump("dumpy.txt");
prlit("dumpy.txt", "===============\n");
@RULES
_xNIL <- _LINE @@
|
@NODES _LINE
@POST
group(2,2,"_item");
@RULES
_xNIL <-
_xSTART ### (1)
_xWILD [fail=(\,)] ### (2)
@@
@POST
group(2,2,"_item");
@RULES
_xNIL <-
\, ### (1)
_xWILD [fail=(\,)] ### (2)
@@ |
# Find and return the concept with name str under the parent concept con.
L("return_con") = findconcept(L("con"), L("str")); |
# Calculate the keyword density
@CODE
G("confidence") = hitconf(5, 100, 17);
@@CODE |
@NODES _LINE
@POST
if (!X("num")) {
if (!X("c")) {
"headers.kbb" << "headers" << "\n";
}
"headers.kbb" << " " << N("$text",1) << "\n";
X("c")++;
}
@RULES
_xNIL <-
_item ### (1)
@@
|
@NODES _ROOT
@POST excise(1,2); @RULES _xNIL <- \[ \[ @@
@POST excise(1,2); @RULES _xNIL <- \] \] @@
@POST excise(1,2); @RULES _xNIL <- \{ \{ @@
@POST excise(1,2); @RULES _xNIL <- \} \} @@
@POST excise(1,2); @RULES _xNIL <- \( \( @@
@POST excise(1,2); @RULES _xNIL <- \) \) @@
@POST excise(1,2); @RULES _xNIL <- \< \< @@
@POST excise(1,2); @RULES _xNIL <- \> \> @@
@POST excise(1,2); @RULES _xNIL <- \> \> @@
@POST excise(1,3); @RULES _xNIL <- \' \' \' [opt] @@
|
@NODES _ROOT
@POST
singler(2,3);
@RULES
_labels <-
_columnHeaders ### (1)
_xWILD [plus fails=(_xEND)] ### (2)
_xEND ### (3)
@@
|
@CODE
L("hello") = 0;
@@CODE
@NODES _TEXTZONE
# Non- eos cases also.
@PRE
<3,3> lowercase();
@POST
noop();
@RULES
_xNIL <-
\.
_xWHITE [star lookahead]
_xALPHA
@@
# Some abbreviatons.
@POST
pncopyvars(1);
S("mypos") = "NP";
single();
@RULES
_companyDESIG [layer=(_abbr _noun)] <-
_xWILD [one match=(inc co corp ltd llc
bancorp)]
\. [opt]
@@
@POST
S("mypos") = "NP";
single();
@RULES
#n.v.
_companyDESIG <-
n
\. [opt]
v
\. [opt]
@@
@POST
S("cap") = 1;
singler(1,2);
@RULES
_abbr [layer=_noun] <-
_xWILD [one match=(mr mrs dr messrs inc jr sen)]
\. [opt]
_xWHITE [star lookahead]
_xCAP
@@
@CHECK
L("txt") = strtolower(N("$text",1));
if (spellword(L("txt"))) # 04/22/07 AM.
fail();
L("len") = strlength(L("txt"));
if (L("len") > 3) # 04/22/07 AM.
fail();
if (finddictattr(L("txt"),"common-cap")) # 04/23/07 AM.
fail();
@POST
L("tmp1") = N(1);
group(1,2,"_abbr");
group(1,1,"_noun");
pncopyvars(L("tmp1"),N(1));
N("cap",1) = 1;
@RULES
_xNIL <-
_xCAP
\.
@@
# Too broad. #
#@PRE
#<1,1> length(2);
#@POST
# S("cap") = 1;
# singler(1,2);
#@RULES
#_abbr [layer=_noun] <-
# _xCAP
# \. [opt]
# _xWHITE [star lookahead]
# _xCAP
# @@
# Period at end of letter abbreviations.
@PRE
<4,4> lowercase();
@POST
listadd(1,2,"false");
@RULES
_xNIL <-
_letabbr
\.
_xWHITE [star lookahead]
_xWILD [one match=(_xALPHA _xPUNCT)]
@@
# letter .
# alpha .
@PRE
<1,1> length(1);
@POST
group(1,2,"_letabbr");
N("cap",1) = 1; # 04/21/07 AM.
@RULES
_xNIL <-
_xCAP
\.
@@
# High confidence end-of-sentence.
#@PRE
#<1,1> lowercase();
@POST
L("txt") = N("$text",2);
if (L("txt") == "?")
S("sent end") = "interrogative";
else if (L("txt") == "!")
S("sent end") = "exclamatory";
singler(2,3);
@RULES
_qEOS <-
_xWILD [one match=(_xALPHA _xNUM \] \) \> \% _noun)]
_xWILD [plus match=( \. \: \; \? \! )]
_xWHITE [star]
_xWILD [one lookahead match=(_xCAP _letabbr \( \[ \< \" \' )]
@@
# Period at end of text zone.
@POST
L("txt") = N("$text",2);
if (L("txt") == "?")
S("sent end") = "interrogative";
else if (L("txt") == "!")
S("sent end") = "exclamatory";
singler(2,3);
@RULES
_qEOS <-
_xWILD [one match=(_xALPHA _xNUM \] \) \> \% _noun)]
_xWILD [plus match=( \. \: \; \? \! )]
_xWHITE [star]
_xEND
@@
# Sentinel.
@PRE
<5,5> lowercase();
@POST
noop();
@RULES
_qEOS <-
_xWILD [one match=(_xALPHA _xNUM )]
\. [plus]
_xWILD [one lookahead match=( \) \] \> )]
_xWHITE [star]
_xALPHA
@@
@POST
singler(2,2);
@RULES
_qEOS <-
_xWILD [one match=(_xALPHA _xNUM )]
\. [plus]
_xWILD [one lookahead match=( \) \] \> )]
@@
# Some may be followed by noncapitalized words.
@POST
singler(2,2);
@RULES
_qEOS <-
_xWILD [one match=(_xALPHA _xNUM _noun \] \) \> \% )]
_xWILD [plus match=( \: \; )]
# _xWHITE [plus]
@@
@RULES
_qEOS <-
\.
\"
@@
@POST
listadd(3,4,"false");
@RULES
_xNIL <-
_xWILD [s one match=(_xPUNCT)]
_xWHITE [star]
_letabbr
\.
@@
# Just a period at end of line, assume ok for now. #
@POST
group(1,1,"_qEOS");
@RULES
_xNIL <-
\.
_xBLANK [star]
\n [lookahead]
@@
# Rearguard.
@POST
++G("unhandled periods");
if (G("error"))
"err1.txt" << "[Unhandled period]" << "\n";
L("n") = N(1);
L("prev") = pnprev(L("n"));
if (L("prev")) L("prev") = pnprev(L("prev"));
L("next") = pnnext(L("n"));
if (L("next")) L("next") = pnnext(L("next"));
if (L("next")) L("next") = pnnext(L("next"));
if (L("prev"))
L("s") = pnvar(L("prev"),"$ostart");
else
L("s") = N("$ostart");
if (L("next"))
L("e") = pnvar(L("next"),"$oend");
else
L("e") = N("$oend");
if (G("error"))
"err1.txt" << " " << inputrange(L("s"),L("e"));
@RULES
_xNIL <-
\. [plus]
@@
# Pre-tagged issue.
# possessive apostrophe
@CHECK
if (N("posarr") != "POS") # possessive.
fail();
@POST
pncopyvars();
S("mypos") = "POS";
single();
@RULES
_aposX <-
\'
@@
# ``
@POST
S("dblquote start") = 1;
S("nopos") = 1;
single();
@RULES
_dblquote <-
\`
\`
@@
# ''
@POST
S("dblquote end") = 1;
S("nopos") = 1;
single();
@RULES
_dblquote <-
\'
\'
@@
# alpha *
@POST
L("tmp1") = N(1);
group(1,2,"_noun");
pncopyvars(L("tmp1"),N(1));
N("text",1) = pnvar(L("tmp1"),"$text");
N("punct end",1) = "*";
if (strisupper(N("text",1)))
chpos(N(1),"NP");
@RULES
_xNIL <- # 19
_xALPHA
\*
@@
# num s
@POST
N("nospace after",1) = 1;
L("num") = N("$text",1);
group(1,2,"_noun");
N("num",1) = L("num");
chpos(N(1),"CD");
@RULES
_xNIL <-
_xNUM
s
@@
# Sentinel.
@POST
noop();
@RULES
_xNIL <-
_xCAP
_xWHITE [star]
_xCAP
\-
_xALPHA
@@
# alpha - alpha
# alpha dash alpha
@POST
L("tmp3") = N(3);
L("txt") = strtolower(N("$text",3));
if (strisupper(N("$text",1)) || strisupper(N("$text",3)))
L("cap") = 1;
if (strisupper(N("$text",3)))
L("cap3") = 1;
if (N("verb",3))
{
L("vc") = vconj(N(3));
if (L("vc") == "-ing"
|| L("vc") == "-en"
|| L("vc") == "-edn")
L("inflected") = 1;
}
if (!spellword(L("txt")) || L("cap"))
{
group(3,3,"_noun");
group(1,3,"_noun");
chpos(N(1),"NP");
}
else if (N("adj",3) || L("inflected"))
{
group(3,3,"_adj");
group(1,3,"_adj");
}
else if (N("noun",3))
{
# Default to adj for now.
L("tmp3") = N(3);
group(3,3,"_noun");
pncopyvars(L("tmp3"),N(3));
fixnoun(N(3));
L("pos") = N("mypos",3);
group(1,3,"_adj");
if (pnvar(L("tmp3"),"sem") == "date")
chpos(N(1),"JJ"); # eg., "five-year".
else
chpos(N(1),L("pos")); # NN or NNS...
}
else
{
# Default to adj for now.
group(3,3,"_adj");
group(1,3,"_adj");
}
N("hyphenated",1) = 1;
if (L("cap"))
N("cap",1) = 1;
if (L("cap3"))
N("pos_np") = "NP"; # 06/08/06 AM.
else
N("pos_np") = "JJ"; # Default. # 06/07/06 AM.
@RULES
_xNIL <-
_xALPHA # [s] buggy -- can't reduce nonlit to lit.
\-
_xALPHA # [s] buggy
@@
# ( letter )
# List item, etc.
@PRE
<2,2> length(1);
@POST
chpos(N(2),"NN");
group(1,3,"_listitem");
group(1,1,"_noun");
@RULES
_xNIL <-
\(
_xALPHA
\)
@@
# Zap single quotes for now. #
@POST
excise(2,2);
@RULES
_xNIL <-
_xWHITE [star]
_xWILD [one match=( \` \' )]
@@
@POST
excise(1,1);
@RULES
_xNIL <-
_xWILD [one match=( \` \' )]
_xWHITE [star]
@@
# Zap all control characters #
@POST
excise(1,1);
@RULES
_xNIL <- _xCTRL @@
|
@CODE
G("kb") = makeconcept(findroot(),"kb");
G("kb_child") = makeconcept(G("kb"), "kb_child");
addstrval(G("kb_child"), "attr", "first attr");
addstrval(G("kb_child"), "attr", "secondattr");
addstrval(G("kb_child"), "attr", "third attr");
G("kb_child_2") = makeconcept(G("kb"), "kb_child_2");
addstrval(G("kb_child_2"), "attr", "first attr");
addstrval(G("kb_child_2"), "attr", "second attr");
addstrval(G("kb_child_2"), "attr", "thirdattr");
SaveKB("mykb.kbb",G("kb"),2);
@@CODE |
@NODES _NLPPP
@POST
preaction()
single()
@RULES
_ACTION [base] <- _PREPAIR _FNCALL [s] \; [s opt] @@
|
@NODES _ROOT
@RULES
_paragraph <-
_xWILD [match=(_LINE)] ### (2)
@@
|
@CODE
L("hello") = 0;
#"metric.txt" << G("$passnum") << "\n";
@@CODE
#@PATH _ROOT _TEXTZONE _sent
@NODES _sent
# dqa alpha alpha
@PRE
<5,5> var("noun");
@CHECK
if (!N(1) && !N(2))
fail();
if (!N("adj",4) && !N("noun",4))
fail();
@POST
fixnphead(5);
fixnpnonhead(4);
if (pnname(N(4)) == "_adj")
L("nn") = 5;
else
L("nn") = 4;
if (pnname(N(4)) == "_adj" && !N(3))
L("jj") = 4;
else
L("jj") = 3;
dqaninfo(1,2,L("jj"),L("nn"));
groupnp();
@RULES
_xNIL <-
_xWILD [star match=(_det _pro)]
_xWILD [star match=(_quan _num _xNUM)]
_adj [star]
_xALPHA
_xALPHA
_xWILD [one lookahead match=(_verb _vg)]
@@
# those alpha to
@POST
if (N("noun",2) && plural(N(2)))
fixnphead(2);
else if (N("verb",2))
alphatoverb(2,0,"VBP");
else if (N("noun",2))
fixnphead(2);
else if (N("adj",2))
alphatoadj(2);
else if (N("adv",2))
alphatoadv(2);
@RULES
_xNIL <-
those [s]
_xALPHA
to [s lookahead]
@@
# det alpha
@CHECK
if (!N("noun",2) && !N("unknown",2))
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_noun");
L("num") = number(L("tmp2"));
if (L("num"))
N("number",2) = L("num");
L("n") = N(2);
pncopyvars(L("tmp2"),N(2));
group(1,2,"_np");
pncopyvars(L("n"),N(1));
clearpos(N(1),1,1);
@RULES
_xNIL <-
_det
_xALPHA
_xWILD [one lookahead match=(_xEND _qEOS)]
@@
# 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",3))
alphatonoun(3);
else
{
if (vconjq(N(3),"-en") && !N("noun",3) && !N("adj",3))
L("pos") = "VBN";
N("verb",3) = 0; # verb = 0
--N("pos num",3);
if (N("noun",3) && N("pos num",3) == 1)
alphatonoun(3); # 04/21/07 AM.
if (L("pos"))
N("mypos",3) = L("pos");
}
@RULES
_xNIL <-
_det
_adv [star]
_xALPHA
@@
# det alpha
# NIBBLE.
@CHECK
if (N("unknown",2))
succeed();
if (!N("verb",2))
fail();
if (N("pos num",2) < 2)
fail();
if (vconjq(N(2),"-ing")
|| vconjq(N(2),"-en"))
fail();
@POST
if (N("unknown",2))
alphatonoun(2);
else if (N("adj",2) && N("noun",2))
fixnpnonhead(2);
else
{
N("verb",2) = 0; # verb = 0
--N("pos num",2);
alphaunambigred(2);
}
@RULES
_xNIL <-
_xWILD [s one match=(while)]
_xALPHA
@@
# det alpha [NIBBLE]
@CHECK
if (N("noun",3) || !N("adj",3))
fail();
@POST
alphatoadj(3);
@RULES
_xNIL <-
_det
_adv [star]
_xALPHA
@@
# alpha verb
# alpha modal
# alpha mhbv
@CHECK
if (!N("noun",3))
fail();
# Todo: Check helping or multi-verb stuff here.
@POST
L("tmp3") = N(3);
group(3,3,"_noun");
pncopyvars(L("tmp3"),N(3));
fixnoun(N(3));
nountonp(3,1);
# semcomposenp(N(3),L("tmp3"),L("tmp3"));
@RULES
_xNIL <-
_xSTART
_xWILD [star match=(_adv _advl)]
_xALPHA
_xWILD [one lookahead match=(_modal _have _be _verb)]
@@
# mhbv conj alpha
@PRE
<11,11> var("verb");
@CHECK
if (!N(1) && !N(3) && !N(5) && !N(7))
fail();
# Agreement...
L("arr") = vgagree(N(1),N(3),N(5),N(7),N(9));
if (!L("arr")[0])
fail();
L("arr") = vgagree(N(1),N(3),N(5),N(7),N(11));
if (!L("arr")[0])
fail();
@POST
L("m") = N(1);
L("h") = N(3);
L("b") = N(5);
L("being") = N(7);
L("v") = N(9);
if (N(7))
{
N("sem",7) = N("stem",7) = "be";
chpos(N(7),"VBG");
}
alphatovg(11,0,0);
L("neg") = mhbvadv(2,4,6,8);
group(1,9,"_vg");
mhbv(N(1),L("neg"),L("m"),L("h"),L("b"),L("being"),L("v"));
# Note: everything renumbered, vg conj vg ...
L("v2") = N("verb node",3);
mhbv(N(3),L("neg"),L("m"),L("h"),L("b"),L("being"),L("v2"));
@RULES
_xNIL <-
_xWILD [s star match=(_modal _do)] ### (1)
_xWILD [star match=(_adv _advl)] ### (2)
_have [s opt] ### (3)
_xWILD [star match=(_adv _advl)] ### (4)
_be [s opt] ### (5)
_xWILD [star match=(_adv _advl)] ### (6)
being [s opt] ### (7)
_xWILD [star match=(_adv _advl)] ### (8)
_xWILD [s one match=(_verb) except=(_modal _have _be _vg)] ### (9)
_conj ### (10)
_xALPHA ### (11)
@@
# mhbv
# Complete vg.
@CHECK
if (pnname(N(9)) != "_verb" && !N("verb",9))
fail();
# Agreement...
L("arr") = vgagree(N(1),N(3),N(5),N(7),N(9));
if (!L("arr")[0])
fail();
@POST
if (pnname(N(9)) != "_verb")
alphatoverb(9,0,0);
L("m") = N(1);
L("h") = N(3);
L("b") = N(5);
L("being") = N(7);
L("v") = N(9);
if (N(7))
{
N("sem",7) = N("stem",7) = "be";
chpos(N(7),"VBG");
}
L("neg") = mhbvadv(2,4,6,8);
group(1,9,"_vg");
mhbv(N(1),L("neg"),L("m"),L("h"),L("b"),L("being"),L("v"));
@RULES
_xNIL <-
_xWILD [s one match=(_modal)] ### (1)
_xWILD [star match=(_adv _advl)] ### (2)
_have [s opt] ### (3)
_xWILD [star match=(_adv _advl)] ### (4)
_be [s opt] ### (5)
_xWILD [star match=(_adv _advl)] ### (6)
being [s opt] ### (7)
_xWILD [star match=(_adv _advl)] ### (8)
_xWILD [s one match=(_verb _xALPHA) except=(_modal _have _be _vg)] ### (9)
@@
# mhbv
@CHECK
if (pnname(N(7)) != "_verb" && !N("verb",7))
fail();
# Agreement...
L("arr") = vgagree(0,N(1),N(3),N(5),N(7));
if (!L("arr")[0])
fail();
@POST
if (pnname(N(7)) != "_verb")
alphatoverb(7,0,0);
L("m") = 0;
L("h") = N(1);
L("b") = N(3);
L("being") = N(5);
L("v") = N(7);
if (N(5))
{
N("sem",5) = N("stem",5) = "be";
chpos(N(5),"VBG");
}
L("neg") = mhbvadv(2,4,6,0);
group(1,7,"_vg");
mhbv(N(1),L("neg"),L("m"),L("h"),L("b"),L("being"),L("v"));
@RULES
_xNIL <-
_have [s]
_xWILD [star match=(_adv _advl)]
_be [s opt]
_xWILD [star match=(_adv _advl)]
being [s opt]
_xWILD [star match=(_adv _advl)]
_xWILD [s one match=(_verb _xALPHA) except=(_modal _have _be _vg)]
@@
# mhbv
@CHECK
if (pnname(N(5)) != "_verb" && !N("verb",5))
fail();
# Agreement...
L("arr") = vgagree(0,0,N(1),N(3),N(5));
if (!L("arr")[0])
fail();
@POST
if (pnname(N(5)) != "_verb")
alphatoverb(5,0,0);
L("m") = 0;
L("h") = 0;
L("b") = N(1);
L("being") = N(3);
L("v") = N(5);
if (N(3))
{
N("sem",3) = N("stem",3) = "be";
chpos(N(3),"VBG");
}
L("neg") = mhbvadv(2,4,0,0);
group(1,5,"_vg");
mhbv(N(1),L("neg"),L("m"),L("h"),L("b"),L("being"),L("v"));
@RULES
_xNIL <-
_be [s] ### (1)
_xWILD [star match=(_adv _advl)] ### (2)
being [s opt] ### (3)
_xWILD [star match=(_adv _advl)] ### (4)
_xWILD [s one match=(_verb _xALPHA) except=(_modal _have _be _vg _adj _adjc)] ### (5)
@@
# verb damn [verb alpha]
# vg damn [vg alpha]
@POST
alphatoadv(3);
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_adv [star]
damn
@@
# prep damn [prep alpha]
@PRE
<1,1> varne("stem","to");
@POST
alphatoadv(3);
@RULES
_xNIL <-
_prep
_adv [star]
damn
@@
# prep alpha dqan
# prep ving dqan
@PRE
<1,1> varne("stem","of");
@CHECK
if (!N("verb",3))
fail();
if (!vconjq(N(3),"-ing"))
fail();
@POST
alphatovg(3,"active",0); # Replace old code. # 05/22/07 AM.
@RULES
_xNIL <-
_prep
_xWILD [star match=(_adv _advl)]
_xALPHA
_xWILD [one lookahead match=(_det _quan _num _prep)]
@@
# while alpha dqan
# when alpha dqan
# when ving dqan
_xNIL <-
_xWILD [s one match=(when while where why)]
_xALPHA
_xWILD [one lookahead match=(_det _quan _num
# _prep
)]
@@
# prep alpha alpha ,
@CHECK
if (!N("noun",3))
fail();
if (!N("noun",2) && !N("adj",2))
fail();
if (!singular(N(2)))
fail();
if (!vconjq(N(3),"-ing"))
fail();
@POST
fixnphead(3);
fixnpnonhead(2);
@RULES
_xNIL <-
_prep
_xALPHA
_xALPHA
_xWILD [one lookahead match=(\,)]
@@
_xNIL <-
_xWILD [s one match=(before)]
_xALPHA
_xALPHA
_xWILD [one lookahead match=(\,)]
@@
# prep alpha ,
@CHECK
if (!N("noun",2) && !N("unknown",2))
fail();
if (N("verb",2))
{
if (vconjq(N(2),"-ing"))
fail();
}
@POST
alphatonoun(2);
@RULES
_xNIL <-
_xWILD [s one match=(_prep) except=(to)]
_xALPHA
_xWILD [one lookahead match=(\, _conj)]
_xWILD [one fail=(_xALPHA _adj)]
@@
_xNIL <-
_xWILD [s one match=(_prep) except=(to)]
_xALPHA
_xWILD [one lookahead match=(_clausesep)]
@@
# prep alpha [NIBBLE]
@CHECK
if (!N("verb",2))
fail();
if (vconjq(N(2),"-ing"))
fail();
@POST
--N("pos num",2);
N("verb",2) = 0; # verb = 0
alphaunambigred(2);
@RULES
_xNIL <-
_xWILD [s one match=(_prep) except=(to)]
_xALPHA
@@
# det alpha alpha noun
# 's alpha alpha noun
# in a double balanced modulator .
@CHECK
if (!N("adj",2))
fail();
if (!N("adj",3) && !N("noun",3))
fail();
if (N("noun",3))
{
if (!singular(N(3)))
fail();
}
if (!singular(N(4)))
fail();
@POST
fixnpnonhead(3);
fixnpnonhead(2);
@RULES
_xNIL <-
_xWILD [one match=(_det _aposS)]
_xALPHA
_xALPHA
_noun
_xWILD [one lookahead match=(_qEOS _xEND _prep)]
@@
# Equation stuff.
@CHECK
if (N("sem",3) != "formula")
fail();
@POST
L("tmp1") = N(1);
group(1,4,"_noun");
pncopyvars(L("tmp1"),N(1));
N("sem",1) = "symbol";
@RULES
_xNIL <-
_noun
\(
_np
\)
@@
# Misc parentheticals.
@POST
group(2,4,"_noun");
@RULES
_xNIL <-
_noun
\(
_xWILD [min=1 max=3 fail=( \) )]
\)
@@
# Question/query/interrogative fixups.
@CHECK
if (!N("verb",3))
fail();
S("vc") = vconj(N(3));
if (S("vc") == "inf"
|| S("vc") == "-ed"
|| S("vc") == "-ing")
fail();
@POST
L("tmp3") = N(3);
group(3,3,"_verb");
pncopyvars(L("tmp3"),N(3));
@RULES
_xNIL <-
_xWILD [s one match=(_have)]
_xWILD [one match=(_noun _np _nps)]
_xALPHA
@@
# Question/query/interrogative fixups.
@CHECK
if (!N("verb",3))
fail();
if (!vconjq(N(3),"-ing"))
fail();
@POST
L("tmp3") = N(3);
group(3,3,"_verb");
pncopyvars(L("tmp3"),N(3));
@RULES
_xNIL <-
_xWILD [s one match=(_be)]
_xWILD [one match=(_noun _np _nps)]
_xALPHA
@@
# cap prep
@CHECK
if (N("verb",2))
{
if (N("noun",2)
&& (vconjq(N(2),"inf") || vconjq(N(2),"-ing")) )
fail();
}
@POST
if (N("noun",2) && plural(N(2)))
fixnphead(2);
else if (N("verb",2))
{
if (N("stem",4) == "by" && vconjq(N(2),"-en"))
alphatovg(2,"passive","VBN");
else
alphatovg(2,0,"VB");
}
else if (N("noun",2))
{
fixnphead(2);
nountonp(2,1);
}
else if (N("adj",2))
alphatoadj(2);
else if (N("adv",2))
alphatoadv(2);
@RULES
_xNIL <-
_xSTART
_xCAP
_xWILD [star match=(_advl _adv)]
_xWILD [one match=(_prep)]
@@
# verb alpha dqan
@CHECK
if (!N("adv",3) || !N("adj",3))
fail();
if (N("pos num",3) != 2)
fail();
@POST
L("tmp3") = N(3);
group(3,3,"_adv");
pncopyvars(L("tmp3"),N(3));
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_xWILD [star match=(_advl _adv)]
_xALPHA
_xWILD [star lookahead match=(_advl _adv)]
_xWILD [one match=(_det _pro _quan _num _xNUM _fnword)]
@@
# verb alpha
@CHECK
if (!N("adv",3) || !N("adj",3))
fail();
if (N("pos num",3) != 2)
fail();
L("txt") = nodesem(N(1));
if (!copulaq(N(1)))
fail();
@POST
L("tmp3") = N(3);
alphatoadj(3);
group(3,3,"_adjc");
pncopyvars(L("tmp3"),N(3));
clearpos(N(3),1,0);
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_xWILD [star match=(_advl _adv)]
_xALPHA
_xWILD [one lookahead fail=(_adj _adjc _xALPHA)]
@@
# that verb
@CHECK
if (pnname(N(2)) != "_fnword")
fail();
if (N("mypos",2))
fail();
if (!vconjq(N(3),"-ed")
&& !vconjq(N(3),"-s"))
fail();
@POST
pnrename(N(2),"_noun"); # rename _fnword.
chpos(N(2),"DT"); # that/DT
@RULES
_xNIL <-
_xSTART
that [s]
_xWILD [one lookahead match=(_modal _verb _vg)]
@@
# , said
@POST
L("t") = strtolower(N("$text",3));
alphatovg(3,"active","VBP");
N("glom",3) = "left";
clearpos(N(3),1,0);
if (L("next") = pnnext(N(3)))
pnreplaceval(L("next"),"glom","right");
N("inverted-verb-noun",3) = 1;
@RULES
_xNIL <-
_xWILD [one match=( \, _dblquote _qEOS _xSTART _conj _clause _noun _np)]
_xWILD [star match=(_advl _adv)]
_xWILD [one match=(say says said quip quips quipped recalls recalled)]
@@
# X said
# cap said
# alpha said
@CHECK
if (N("stem",2) != "say")
fail();
@POST
L("tmp1") = N(1);
group(1,1,"_noun");
pncopyvars(L("tmp1"),N(1));
N("ne type",1) = N("sem",1) = "person";
N("ne type conf",1) = 60;
N("stem",1) = N("$text",1);
if (singular(N(1)))
chpos(N(1),"NP");
else
chpos(N(1),"NPS");
if (pnname(N(2)) != "_verb")
{
L("tmp2") = N(2);
group(2,2,"_verb");
pncopyvars(L("tmp2"),N(2));
L("v") = N(2);
group(2,2,"_vg");
mhbv(N(2),L("neg"),0,0,0,0,L("v"));
pncopyvars(L("tmp2"),N(2));
N("verb node",2) = L("v");
clearpos(N(2),1,0);
fixvg(N(2),"active",0);
}
@RULES
_xNIL <-
_xCAP
_xWILD [one match=(_verb say says saying said
quip quips quipping quipped recalls recalled)]
@@
# last noun
# last date
@CHECK
if (N("sem",2) != "date")
fail();
@POST
alphatoadj(1);
@RULES
_xNIL <-
last
_noun [lookahead]
@@
# alpha alpha
# alpha date
@PRE
<1,1> varz("adj"); # First alpha is not an adj.
<2,2> vareq("sem","date"); # Second alpha is a date.
@CHECK
if (!N("noun",1) && !N("verb",1))
fail();
if (!N("noun",2) || !N("adv",2))
fail();
@POST
# NLP++: don't know if the lookahead can safely be reduced.
L("tmp2") = N(2);
group(2,2,"_adv");
pncopyvars(L("tmp2"),N(2));
@RULES
_xNIL <-
_xALPHA
_xALPHA
_xWILD [one lookahead fail=(_aposS)]
@@
# alpha alpha #
# alpha date
@PRE
<1,1> var("verb"); # First alpha can be verb.
<2,2> vareq("sem","date"); # Second alpha is a date.
@CHECK
if (vconjq(N(1),"inf")
|| vconjq(N(1),"-s"))
fail();
if (!N("noun",2) || !N("adv",2))
fail();
@POST
# NLP++: lookahead cannot safely be reduced.
L("tmp2") = N(2);
group(2,2,"_adv");
pncopyvars(L("tmp2"),N(2));
@RULES
_xNIL <-
_xALPHA
_xALPHA
_xWILD [one lookahead fail=(_aposS)]
@@
# alpha date
# last date
# next date.
@PRE
<2,2> vareq("sem","date");
@POST
alphatoadj(1);
@RULES
_xNIL <-
_xWILD [one match=(last next)]
_noun
@@
# since early July.
# since alpha noun.
@PRE
<2,2> var("adj");
@POST
alphatoadj(2);
@RULES
_xNIL <- # 04/20/07 AM.
_xWILD [s one match=(since _det)]
_xALPHA
_noun [lookahead]
@@
# alpha date
# alpha noun
# Note: Assume date item doesn't glom. If it does,
# assume that was handled already.
@PRE
<2,2> vareq("sem","date");
@POST
L("tmp2") = N(2);
if ((N("noun",1) || N("adj",1))
&& !N("adv",1) && !N("verb",1))
{
fixnpnonhead(1);
group(1,2,"_np");
pncopyvars(L("tmp2"),N(1));
clearpos(N(1),1,1);
}
else
{
nountonp(2,1);
}
@RULES
_xNIL <-
_xALPHA
_noun
_xWILD [one lookahead fail=(_aposS _noun _xALPHA)]
@@
_xNIL <-
_xALPHA
_noun
_xEND
@@
# though
@POST
pnrename(N(2),"_adv");
chpos(N(2),"RB"); # Override pos.
@RULES
_xNIL <-
\,
though [s]
_xWILD [one lookahead match=(\, _qEOS _xEND)]
@@
# including
# note: as prepositional construct.
@PRE
<2,2> varz("pos25 including");
@POST
N("pos25 including",2) = 1;
if (pnname(N(2)) == "_verb")
pnrename(N(2),"_prep"); # including -> prep
# chpos(N(2),"IN");
chpos(N(2),"VBG"); # Conform to Treebank.
@RULES
_xNIL <-
_xWILD [one fail=(_be )]
including [s]
@@
# still
@POST
L("tmp1") = N(1);
group(1,1,"_adv");
pncopyvars(L("tmp1"),N(1));
chpos(N(1),"RB");
@RULES
_xNIL <-
still
_xWILD [one lookahead match=(_verb _vg _prep _adv _advl)]
@@
# than those prep
#@POST
# pnrename(N(2),"_noun");
#@RULES
#_xNIL <-
# than [s]
# _xWILD [s one match=(these those)]
# _prep [lookahead]
# @@
# num noun
# note: number as adjective.
@CHECK
if (!singular(N(2)))
fail();
@POST
L("tmp1") = N(1);
group(1,1,"_adj");
pncopyvars(L("tmp1"),N(1));
chpos(N(1),"CD");
N("numeric",1) = 1;
@RULES
_xNIL <-
_xNUM
_noun
@@
# alpha enough
@POST
L("tmp1") = N(1);
L("tmp2") = N(2);
group(2,2,"_adv");
pncopyvars(L("tmp2"),N(2));
group(1,1,"_adj");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
_xWILD [one match=(good bad)]
enough
@@
# Some default tagging.
@PRE
<3,3> varz("done");
@POST
N("done",3) = 1;
chpos(N(3),"VB");
@RULES
_xNIL <-
_xWILD [s one match=(to _modal _do)]
_xWILD [star match=(_adv _advl)]
have [s]
@@
@POST
L("tmp1") = N(1);
group(1,1,"_prep");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
unlike
@@
# prep that alpha $
@CHECK
if (!N("noun",3))
fail();
@POST
if (!N("mypos",2))
chpos(N(2),"DT"); # that/DT.
L("tmp3") = N(3);
group(3,3,"_noun");
pncopyvars(L("tmp3"),N(3));
@RULES
_xNIL <-
_xWILD [one match=(_prep)]
that [s]
_xALPHA
_xWILD [one lookahead match=(_xEND)]
@@
# prep that
# on that
@PRE
<2,2> varz("mypos");
@POST
chpos(N(2),"DT"); # that/DT.
pnrename(N(2),"_det");
@RULES
_xNIL <-
_xWILD [s one match=(on)]
that [s]
@@
# that adj $
# "that green" <=> "so green".
#@CHECK
# if (N("mypos",1))
# fail();
#@POST
# chpos(N(1),"RB"); # that/RB
#@RULES
#_xNIL <-
# that [s]
# _adj [lookahead]
# _xEND
# @@
#_xNIL <-
# that [s]
# _adj [lookahead]
# _xWILD [one fail=(_adj _noun \, _xALPHA)]
# @@
# that alpha noun noun alpha $
@CHECK
if (!N("verb",2))
fail();
if (!N("noun",5))
fail();
if (!vconjq(N(2),"-ed")
&& !vconjq(N(2),"-s")
&& !vconjq(N(2),"inf"))
fail();
if (!singular(N(4)))
fail();
if (!plural(N(5)))
fail();
@POST
L("tmp2") = N(2);
L("tmp5") = N(5);
group(5,5,"_noun");
pncopyvars(L("tmp5"),N(5));
group(2,2,"_verb");
pncopyvars(L("tmp2"),N(2));
fixverb(N(2),"active","VBP");
if (!N("mypos",1))
chpos(N(1),"IN"); # that/IN
@RULES
_xNIL <-
that [s]
_xALPHA
_noun
_noun
_xALPHA
_xWILD [one match=(_xEND)]
@@
# det that verb $
# ex: all that required.
# Ellipted: "all that that required"
@CHECK
if (pnname(N(2)) == "_np")
fail();
if (N("mypos",2))
fail();
if (!vconjq(N(3),"-ed")
&& !vconjq(N(3),"-s"))
fail();
@POST
pnrename(N(2),"_det");
chpos(N(2),"DT"); # that/DT
nountonp(2,1);
nountonp(1,1);
@RULES
_xNIL <-
_det
that [s]
_xWILD [one match=(_verb _vg)]
_xEND
@@
# more noun
@CHECK
if (N("mypos",1))
fail();
@POST
chpos(N(1),"JJR");
pnrename(N(1),"_adj");
@RULES
_xNIL <-
_xWILD [s one match=(more less)]
_xWILD [one lookahead match=(_noun _np)]
@@
# most noun
@CHECK
if (N("mypos",1))
fail();
@POST
chpos(N(1),"JJS");
if (pnname(N(1)) == "_fnword")
pnrename(N(1),"_adj");
@RULES
_xNIL <-
most [s]
_xWILD [one lookahead match=(_noun _np)]
@@
# far more
# alpha fnword
# alpha more
@CHECK
if (N("pos num",1) != 2)
fail();
if (!N("adj",1) || !N("adv",1))
fail();
@POST
L("tmp1") = N(1);
group(1,1,"_adv");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
_xALPHA
_xWILD [s one lookahead match=(more less)]
@@
# more alpha
@CHECK
if (!N("adj",2))
fail();
@POST
if (N("mass",2))
{
alphatonoun(2);
if (!N("mypos",1))
chpos(N(1),"JJR");
}
else
{
alphatoadj(2);
if (!N("mypos",1))
chpos(N(1),"RBR");
}
chpos(N(1),"RBR"); # more/RBR.
pnrename(N(1),"_adj");
@RULES
_xNIL <-
_xWILD [s one match=(more less)]
_xALPHA
@@
# most alpha
@CHECK
if (!N("adj",2))
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_adj");
pncopyvars(L("tmp2"),N(2));
fixadj(N(2));
if (!N("mypos",1))
chpos(N(1),"RB"); # most/RJS
if (pnname(N(1)) == "_fnword")
pnrename(N(1),"_adv");
@RULES
_xNIL <-
most [s]
_xALPHA
\, [lookahead]
_xWILD [one fail=(_xALPHA _adj)]
@@
# det most adj
# pro most adj
@POST
chpos(N(2),"RBS"); # most/RBS
pnrename(N(2),"_premod");
group(2,3,"_adj");
@RULES
_xNIL <-
_xWILD [one match=(_det _pro)]
most [s]
_adj
@@
# most adj
# Note: If the above not matched, then most is adj.
@PRE
<1,1> varz("pos25 most-adj");
@POST
N("pos25 most-adj",1) = 1;
chpos(N(1),"JJS"); # most/JJS
pnrename(N(1),"_adj");
@RULES
_xNIL <-
most [s]
_adj [lookahead]
@@
# most alpha
@CHECK
if (!N("adj",3))
fail();
@POST
alphatoadj(3);
if (!N("mypos",2))
{
if (N(1))
chpos(N(2),"RBS"); # most/RBS
else
chpos(N(2),"JJS"); # most/JJS
}
pnrename(N(2),"_adj"); # most -> adj
@RULES
_xNIL <-
_xWILD [opt match=(_det _pro)]
most [s]
_xALPHA
@@
# , up
# , down
# up
# down
@CHECK
if (N("mypos",3))
fail();
@POST
if (!N("mypos",3))
chpos(N(3),"RB");
@RULES
_xNIL <-
_xWILD [one match=(_xSTART \, _dbldash \- )]
_xWILD [star match=(_adv _advl)]
_xWILD [s one lookahead match=(up down)]
@@
# verb prep prep
@PRE
<2,2> varz("mypos");
@CHECK
if (pnname(N(1)) == "_vg")
{
L("v") = N("verb node",1);
if (N("voice",1) != "active" && vconjq(L("v"),"-en"))
fail();
}
else
{
if (!N("mypos",1) || N("mypos",1) == "VBN")
fail();
}
@POST
if (!N("mypos",2))
chpos(N(2),"IN"); # prep/IN
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_prep [lookahead]
_prep
@@
# be up
# be down
# up
# down
# copula
# Note: "is off" -- some assign this as ADJ.
@CHECK
if (N("mypos",3))
fail();
L("txt") = nodesem(N(1));
S("copula") = copulaq(N(1));
# Also check phrasal/prepositional.
S("rp/in") = phrprepverbq(N(1),N(3));
if (!S("copula") && !S("rp/in"))
fail();
@POST
# If both, don't know how to decide.
# Prefer prep/phrasal for now.
if (S("rp/in") == 1 # PHRASAL.
|| S("rp/in") == 3) # Ambig. Choose phrasal, slight pref.
chpos(N(3),"RP");
else if (S("rp/in") == 2) # PREPOSITIONAL.
chpos(N(3),"IN");
else # Must be copula case.
chpos(N(3),"RB"); # up/RB down/RB out/RB off/RB
# Reduce verb+particle to vg.
if (pnname(N(1)) == "_vg" && S("rp/in"))
{
N("particle",1) = N(3);
listadd(1,3,"true"); # Glom it together.
}
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_xWILD [star match=(_adv _advl)]
_xWILD [s one lookahead match=(up down out off)]
@@
# noun alpha up
# noun alpha down
# up
# down
# out
@CHECK
if (!N("verb",3))
fail();
# Require prepositional/phrasal verb.
S("num") = phrprepverbq(N(3),N(5));
if (!S("num"))
fail();
@POST
if (!N("mypos",5))
{
if (N("stem",5) == "to")
chpos(N(5),"TO");
else if (S("num") == 2)
chpos(N(5),"IN");
else # 1 or 3
chpos(N(5),"RP");
}
L("tmp3") = N(3);
group(3,3,"_verb");
pncopyvars(L("tmp3"),N(3));
@RULES
_xNIL <-
_xWILD [one match=(_noun _np)]
_xWILD [plus match=(_adv _advl)] # 04/20/07 AM.
_xALPHA
_xWILD [star match=(_adv _advl)]
# _xWILD [s one lookahead match=(up down out off)]
_prep [lookahead]
@@
# clausal
# verb noun prep
# Check for phrasal verb.
@CHECK
if (N("mypos",5))
fail();
if (N("pos25-particle",5))
fail();
@POST
N("pos25-particle",5) = 1;
if (copulaq(N(1)))
{
chpos(N(5),"IN"); # eg, UP % # 06/15/06 AM.
}
# See if kb has something. #
else if (L("num") = phrprepverbq(N(1),N(5)))
{
if (L("num") == 2) # prepositional. # FIX. 06/18/06 AM.
chpos(N(5),"IN");
else # 1 or 3.
chpos(N(5),"RP"); # Default.
}
# else # Default.
# chpos(N(5),"RP");
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_xWILD [star lookahead match=(_adv _advl)]
_xWILD [one match=(_noun _np)]
_xWILD [star match=(_adv _advl)]
_prep
_xWILD [one match=(_prep _advl \, _dbldash _xEND)]
@@
_xNIL <-
_xWILD [one match=(_verb _vg)]
_xWILD [star lookahead match=(_adv _advl)]
_xWILD [one match=(_noun _np)]
_xWILD [star match=(_adv _advl)]
_xWILD [s one match=(up down out off)]
@@
# as alpha prep
@CHECK
if (!N("adj",2))
fail();
if (N("verb",2) || N("noun",2))
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_adj");
pncopyvars(L("tmp2"),N(2));
fixadj(N(2));
pnrename(N(1),"_adv");
if (!N("mypos",1))
chpos(N(1),"RB");
@RULES
_xNIL <-
as [s]
_xALPHA
_xWILD [one lookahead match=(_prep)]
@@
# as yet
@CHECK
if (N("mypos",1) && N("mypos",2))
fail();
@POST
if (!N("mypos",2))
{
chpos(N(2),"RB");
pnrename(N(2),"_adv");
}
if (!N("mypos",1))
{
chpos(N(1),"RB");
pnrename(N(1),"_adv");
}
@RULES
_xNIL <-
as [s]
yet [s]
@@
# as adj as
# as adj det
@PRE
<1,1> varz("mypos");
@POST
pnrename(N(1),"_adv"); # as -> adv.
chpos(N(1),"RB"); # as/RB
@RULES
_xNIL <-
as [s]
_adj
_xWILD [s one lookahead match=(_det as)]
@@
# as dqan verb
@PRE
<1,1> varz("mypos");
@POST
chpos(N(1),"IN");
@RULES
_xNIL <-
as [s]
_xWILD [plus lookahead match=(_det _pro _quan _num _xNUM
_adj _noun _np _xALPHA)]
_xWILD [one match=(_verb _vg)]
@@
# as
@CHECK
if (N("mypos"))
fail();
@POST
chpos(N(1),"IN"); # as/IN
pnrename(N(1),"_prep");
@RULES
_xNIL <-
as [s]
@@
# yet whether
@CHECK
if (N("mypos",1))
fail();
@POST
chpos(N(1),"RB"); # yet/RB.
pnrename(N(1),"_adv");
@RULES
_xNIL <-
yet [s]
_fnword [lookahead]
@@
# no adv
@CHECK
if (N("mypos",1))
fail();
@POST
chpos(N(1),"RB");
pnrename(N(1),"_adv");
@RULES
_xNIL <-
no [s]
_adv [lookahead]
@@
# , compared
# compared
@CHECK
if (N("mypos",2))
fail();
@POST
chpos(N(2),"VBN");
N("voice",2) = "passive";
N("-en",2) = 1;
@RULES
_xNIL <-
_xWILD [s one match=(_xSTART \, when if as)]
compared [s]
@@
# alpha 's
# alpha '
@CHECK
if (!N("noun",1))
fail();
@POST
L("tmp1") = N(1);
group(1,1,"_noun");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
_xALPHA
_xWILD [one lookahead match=(_aposS _aposX)]
@@
# once dqan
#@CHECK
# if (N("mypos",1))
# fail();
@POST
chpos(N(1),"IN"); # once/IN
@RULES
_xNIL <-
once [s]
_xWILD [one lookahead match=(_noun _np _det _pro
_quan _num _xNUM _adj )]
@@
# num 's
@POST
if (!N("mypos",2))
chpos(N(2),"POS"); # 's/POS
group(1,2,"_adj");
N("ignorepos",1) = 1;
@RULES
_xNIL <-
_xNUM
_aposS
@@
# 's not verb
@CHECK
if (!vconjq(N(4),"-en")
&& !vconjq(N(4),"-ing"))
fail();
@POST
L("tmp2") = N(2);
pnrename(N(2),"_be");
group(2,2,"_verb");
pncopyvars(L("tmp2"),N(2));
chpos(N(2),"VBZ"); # 's/VBZ
N("copula",2) = 1;
@RULES
_xNIL <-
_xWILD [one match=(_noun _np _xALPHA)]
_aposS
_neg [s]
_xWILD [one match=(_verb)]
@@
# 's not dqan
@POST
L("tmp2") = N(2);
pnrename(N(2),"_be");
group(2,2,"_verb");
pncopyvars(L("tmp2"),N(2));
chpos(N(2),"VBZ");
N("apos-s",2) = 1;
@RULES
_xNIL <-
_xWILD [one match=(_noun _np _xALPHA)]
_aposS
_neg [s]
_xWILD [one match=(_np _det _pro _quan _num _xNUM
_adj _noun)]
@@
# cap 's said
# Webster's said
# Note: actually, ambiguous verb/noun.
@POST
chpos(N(1),"NP");
chpos(N(2),"POS");
L("tmp1") = N(1);
group(1,2,"_noun");
pncopyvars(L("tmp1"),N(1));
clearpos(N(1),1,0);
N("apos-s",1) = 1;
@RULES
_xNIL <-
_xCAP [s]
_aposS
_xWILD [star lookahead match=(_adv _advl)]
said [s]
@@
_xNIL <-
_xCAP [s]
_aposS
_xWILD [star lookahead match=(_adv _advl)]
_xWILD [one match=(_verb _modal _vg)]
@@
# 's alpha
@CHECK
if (!N("noun",2))
fail();
if (N("adj",2))
fail();
if (!singular(N(2)))
fail();
@POST
if (!N("mypos",1))
chpos(N(1),"POS"); # 's/POS
alphatonoun(2);
@RULES
_xNIL <-
_aposS
_xALPHA
@@
# 's alpha
@CHECK
if (N("mypos",1))
fail();
if (N("verb",2))
{
if (!vconjq(N(2),"-s")
&& !vconjq(N(2),"inf"))
fail();
}
else if (N("noun",2))
{
if (!plural(N(2)))
fail();
}
@POST
chpos(N(1),"POS"); # 's/POS
@RULES
_xNIL <-
_aposS
_xALPHA [lookahead]
@@
# noun 's $
@POST
chpos(N(2),"POS"); # 's/POS
group(1,2,"_adj");
N("apos-s",1) = 1;
@RULES
_xNIL <-
_noun
_aposS
_xWILD [one lookahead match=(_dbldash _xEND)]
@@
# 's $
@POST
chpos(N(1),"POS"); # 's/POS
@RULES
_xNIL <-
_aposS
_xWILD [one match=(_dbldash _xEND)]
@@
# adj alpha
@CHECK
if (!N("noun",2) && !N("unknown",2))
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_noun");
pncopyvars(L("tmp2"),N(2));
@RULES
_xNIL <-
_adj
_xALPHA
_xWILD [one lookahead match=(_xEND _advl _conj _dbldash _fnword
_modal _prep _verb _vg)]
@@
# det alpha
_xNIL <-
_det
_xALPHA
_xWILD [one lookahead match=(_verb _vg)]
@@
# adj alpha
@PRE
<2,2> var("noun");
<2,2> var("verb");
@CHECK
if (N("pos num",2) != 2)
fail();
@POST
alphatonoun(2);
@RULES
_xNIL <-
_adj
_xALPHA
@@
# conj alpha prep
@PRE
<2,2> varz("noun");
@CHECK
if (!N("verb",2))
fail();
if (!vconjq(N(2),"-ing")
&& !vconjq(N(2),"-edn"))
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_verb");
pncopyvars(L("tmp2"),N(2));
@RULES
_xNIL <-
_conj
_xALPHA
_xWILD [one lookahead match=(_prep)]
@@
# conj alpha noun
@POST
L("done") = 0; # If found something.
if (N("noun",2) || N("adj",2))
{
if (singular(N(3)) && !N("cap",3))
{
fixnpnonhead(2);
L("done") = 1;
}
}
noop();
@RULES
_xNIL <-
_conj
_xALPHA
_noun [lookahead]
_xWILD [one match=(_prep)]
@@
# fnword alpha verb
# conj alpha verb
@CHECK
if (!N("noun",2) && !N("unknown",2))
fail();
# if (vconjq(N(2),"-ing")
# || vconjq(N(2),"-edn"))
# fail();
@POST
L("tmp2") = N(2);
group(2,2,"_noun");
pncopyvars(L("tmp2"),N(2));
@RULES
_xNIL <-
_xWILD [one match=(_fnword _conj)]
_xALPHA
_xWILD [one lookahead match=(_verb _vg _modal)]
@@
# fnword alpha alpha
@PRE
<3,3> var("verb");
<5,5> var("adv");
@POST
alphatoadv(5);
alphatovg(3,0,0);
@RULES
_xNIL <-
but [s]
_adv [star]
_xALPHA
_adv [star]
_xALPHA
_xWILD [one match=(_np _pro _det _quan _num _xNUM)]
@@
# noun alpha verb
@CHECK
if (!N("noun",2) && !N("unknown",2))
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_noun");
pncopyvars(L("tmp2"),N(2));
posacct(N(2));
@RULES
_xNIL <-
_noun
_xALPHA
_xWILD [one lookahead match=(_modal _verb _vg)]
@@
# idiom: pretty much
# much
@POST
L("tmp1") = N(1);
L("tmp2") = N(2);
group(2,2,"_adv");
pncopyvars(L("tmp2"),N(2));
group(1,1,"_adv");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
pretty
much
@@
# that num ,
# that money ,
@CHECK
if (N("mypos",1) && N("mypos",1) != "DT")
fail();
@POST
chpos(N(1),"DT"); # that/DT.
pnrename(N(1),"_det");
@RULES
_xNIL <-
that [s except=(_det)]
_num
_xWILD [one lookahead match=( \, )]
@@
# that noun $
# that dqan $
@CHECK
if (N("mypos",1))
fail();
@POST
chpos(N(1),"DT"); # that/DT.
if (pnname(N(1)) == "_fnword")
pnrename(N(1),"_det");
@RULES
_xNIL <-
that [s]
_adj [star]
_noun [plus]
_xWILD [one match=(_xEND _qEOS _dbldash)]
@@
# that $
@CHECK
if (N("mypos",1))
fail();
@POST
chpos(N(1),"DT"); # that/DT.
if (pnname(N(1)) == "_fnword")
pnrename(N(1),"_noun");
@RULES
_xNIL <-
that [s]
_xWILD [one match=(_xEND _qEOS _dbldash)]
@@
# that alpha
# Idiomatic or highly preferred cases.
@POST
L("tmp3") = N(3);
group(3,3,"_verb");
pncopyvars(L("tmp3"),N(3));
@RULES
_xNIL <-
that [s]
_xWILD [star match=(_adv _advl)]
_xWILD [one match=(uses)]
@@
# alpha noun
# gives us
@POST
L("tmp1") = N(1);
group(1,1,"_verb");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
gives
_xWILD [one lookahead match=(_pro _det _quan _num _xNUM _adj _noun _np)]
@@
# noun adj noun
@CHECK
if (!N("cap",2) && !N("num",2) && !N("possessive",3))
fail();
@POST
pnrename(N(2),"_adj"); # noun -> adj
@RULES
_xNIL <-
_xWILD [one match=(_det _prep _pro _conj)]
_noun
_adj [plus]
_noun
@@
# these alpha
# those alpha
# plural alpha
@CHECK
if (!N("noun",2))
fail();
if (!plural(N(2)))
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_noun");
pncopyvars(L("tmp2"),N(2));
# _np
@RULES
_xNIL <-
_xWILD [s one match=(these those)]
_xALPHA
_xWILD [one lookahead fail=(_xALPHA _noun)]
@@
_xNIL <-
_xWILD [s one match=(these those)]
_xALPHA
_xEND
@@
# such alpha alpha
# plural reasoning.
@POST
if (plural(N(3)))
{
L("done") = 1;
fixnphead(3);
}
else if (vconjq(N(3),"-ing"))
L("done") = 1;
if (!L("done") && N(4))
{
if (plural(N(4)))
{
L("done") = 1;
fixnphead(4);
fixnpnonhead(3);
}
else if (vconjq(N(4),"-ing"))
L("done") = 1;
}
if (!L("done") && N(5))
{
if (plural(N(5)))
{
L("done") = 1;
fixnphead(5);
fixnpnonhead(4);
fixnpnonhead(3);
}
else if (vconjq(N(5),"-ing"))
L("done") = 1;
}
@RULES
_xNIL <-
_xWILD [one fail=(no)]
such [s]
_xALPHA
_xALPHA [opt]
_xALPHA [opt]
@@
# ever verb
@POST
pnrename(N(1),"_adv");
@RULES
_xNIL <-
_xWILD [s one match=(ever) except=(_adv)]
_xWILD [one lookahead match=(_verb _vg)]
@@
# ^ like dqan
@CHECK
if (N("mypos",3))
fail();
if (pnname(N(3)) != "_fnword")
fail();
@POST
pnrename(N(3),"_prep");
@RULES
_xNIL <-
_xWILD [one match=(_xSTART \( _dbldash \, )]
_xWILD [star match=(_conj _adv _advl)]
like [s]
_xWILD [star match=(_adv _advl)]
_xWILD [one lookahead match=(_np _noun
_det _quan _adj _num _xNUM
)]
@@
# something like
@CHECK
if (N("mypos",2))
fail();
if (pnname(N(2)) != "_fnword")
fail();
@POST
pnrename(N(2),"_prep");
@RULES
_xNIL <-
_xWILD [s one match=(something someone somewhat
somewhere somehow someplace sometime
)]
like [s]
@@
# alpha like
@CHECK
if (pnname(N(2)) != "_fnword")
fail();
if (N("pos num",1) != 2)
fail();
if (!N("verb",1) || !N("adj",1))
fail();
@POST
# Don't commit to verb-adj yet.
pnrename(N(2),"_prep");
@RULES
_xNIL <-
_xALPHA
like [s]
@@
# verb num
@POST
nountonp(2,1);
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_xWILD [one match=(_num _quan _xNUM)]
_xWILD [one lookahead match=(_fnword _prep _verb _vg
_det _np)]
@@
# this
# Fixup of lone determiner.
@CHECK
if (pnname(N(1)) != "_det")
fail();
@POST
group(1,1,"_noun");
nountonp(1,1);
@RULES
_xNIL <-
this [s]
_adv [star]
_xWILD [one lookahead match=(_advl _np _vg
_pro _modal _verb _fnword _prep _conj
)]
@@
# to alpha
@CHECK
if (!N("verb",3))
fail();
if (!vconjq(N(3),"inf")) # New function. # 06/15/06 AM.
fail();
@POST
alphatovg(3,"active","VB");
@RULES
_xNIL <-
to [s]
_xWILD [star match=(_adv _advl)]
_xALPHA
_xWILD [star match=(_adv _advl)]
_xWILD [lookahead one match=(
_det _quan _num _xNUM _adj _np _pro)]
@@
# to alpha
@PRE
<1,1> varz("pos25 to-alph");
@CHECK
if (N("adj",2) && N("verb",2) && vconjq(N(2),"-ing"))
fail();
@POST
N("pos25 to-alph",1) = 1;
if (N("unknown",2))
alphatonoun(2);
else if (vconjq(N(2),"-ing"))
{
if (N("adj",2))
alphatoadj(2);
else
alphatoverb(2,"active","VBG");
}
else if (N("verb",2))
{
if (vconjq(N(2),"inf")
&& !plural(N(2)) )
{
# Still ambiguous. #
# alphatoverb(2,"active","VB"); #
}
else if (vconjq(N(2),"-en")
|| vconjq(N(2),"-ing"))
alphatoadj(2);
else if (N("noun",2))
alphatonoun(2);
else
{
"err.txt" << "pos50 to-alpha: " << phrasetext() << "\n";
alphatoverb(2,"active","VB"); # verb/VB [DEFAULT]
}
}
else if (N("adj",2))
alphatoadj(2);
else if (N("noun",2))
alphatonoun(2);
else if (N("adv",2))
alphatoadv(2);
else # [DEFAULT]
{
"err.txt" << "pos50 to-alpha: " << phrasetext() << "\n";
alphatoverb(2,"active","VB"); # verb/VB [DEFAULT]
}
@RULES
_xNIL <-
to [s]
_xALPHA
@@
# , but
# Note: Finding different types of commas.
@POST
group(1,1,"_clausesep");
@RULES
_xNIL <-
\,
but [s lookahead]
@@
# verb yet
@CHECK
if (N("mypos",3))
fail();
if (!N("verb",4))
fail();
if (!vconjq(N(4),"-en"))
fail();
@POST
chpos(N(3),"RB"); # yet/RB.
pnrename(N(3),"_adv");
@RULES
_xNIL <-
_xWILD [s one match=(_modal _have _be being)]
_adv [star]
yet [s]
_xWILD [one lookahead match=(_xALPHA _verb)]
@@
# have
@PRE
<1,1> varz("done");
@POST
N("done",1) = 1;
chpos(N(1),"VBP");
@RULES
_xNIL <-
have [s]
@@
# adv alpha
@CHECK
if (!N("verb",2))
fail();
if (!vconjq(N(2),"-ing"))
fail();
@POST
alphatoverb(2,"active","VBG");
@RULES
_xNIL <-
_neg [s]
_xALPHA
@@
# det date alpha
# det noun alpha
# dqan alpha
# NIBBLE.
@CHECK
if (N("sem",3) != "date"
&& !N("cap",3))
fail();
if (!N("noun",4))
fail();
if (N("verb",4))
{
if (vconjq(N(4),"-ed") || vconjq(N(4),"-ing"))
fail();
if (singular(N(3)) && singular(N(4)))
succeed();
fail();
}
@POST
alphatonoun(4); # adjnoun thingy.
# Fix some caps from context.
if (N("mypos",3) == "NPS" && N("unknown",3) && singular(N(4)))
N("mypos",4) = "NP"; # noun(pl) -> noun(s)
@RULES
_xNIL <-
_xWILD [one match=(_det _pro)]
_adj [star]
_xWILD [one match=(_noun _np)]
_xALPHA
_xWILD [one lookahead fail=(_pro _noun _np)]
@@
# det noun alpha $
@PRE
<3,3> var("noun");
@CHECK
if (N("unknown",2) && N("cap",2) && N("mypos",2) == "NPS")
succeed();
fail();
@POST
N("mypos",2) = "NP";
fixnphead(3);
@RULES
_xNIL <-
_det
_noun
_xALPHA
_xEND
@@
# alpha modal
@CHECK
if (!N("noun",1))
fail();
if (N("verb"))
{
if (vconjq(N(1),"-ing")
|| vconjq(N(1),"-en"))
fail();
}
@POST
fixnphead(1);
@RULES
_xNIL <-
_xALPHA
_modal [lookahead]
@@
# prep noun alpha conj verb
# prep dqan alpha conj verb
@CHECK
# Todo: check v-v agreement.
if (!N("noun",6))
fail();
if (vvagree(N(6),N(8)))
fail();
@POST
fixnphead(6);
@RULES
_xNIL <-
_prep
_xWILD [star match=(_det _pro)]
_xWILD [star match=(_quan _num _xNUM)]
_adj [star]
_noun [star]
_xALPHA
_conj [lookahead]
_xWILD [one match=(_modal _verb _vg)]
@@
# det verb
# the verb
@POST
pnrename(N(2),"_adj"); # verb -> adj
chpos(N(2),"JJ");
@RULES
_xNIL <-
_xWILD [s one match=(a the _premod)]
_verb
@@
# alpha by
@CHECK
if (!N("verb",1))
fail();
if (!vconjq(N(1),"-en"))
fail();
@POST
alphatoverb(1,0,0);
@RULES
_xNIL <-
_xALPHA
by [s lookahead]
@@
# alpha than
# Note: test comparative adj.
@CHECK
L("txt") = strtolower(N("$text",1));
L("j") = adjconj(L("txt"));
if (L("j") != "JJR")
fail();
@POST
alphatoadj(1);
@RULES
_xNIL <-
_xALPHA
than [s lookahead]
@@
# , alpha prep
@CHECK
if (!N("noun",2))
fail();
if (N("verb",2) || N("adv",2))
fail();
@POST
fixnphead(2);
@RULES
_xNIL <-
_xWILD [one match=( \, )]
_xALPHA
_xWILD [one lookahead match=(_prep)]
@@
# whose alpha
@POST
if (N("verb",2))
{
N("verb",2) = 0; # verb = 0
--N("pos num",2);
}
alphaunambigred(2);
@RULES
_xNIL <-
whose [s]
_xALPHA
@@
# det num alpha alpha
@CHECK
if (!N("noun",3) && !N("adj",3))
fail();
@POST
if (plural(N(3)))
fixnphead(3);
else if (N("noun",4))
{
fixnpnonhead(3);
if (plural(N(4)))
fixnphead(4);
}
@RULES
_xNIL <-
_xWILD [opt match=(_det _pro)]
_xWILD [one match=(_xNUM _num _quan)]
_xALPHA
_xALPHA
@@
# dqan alpha adj
# Post-np adj. ("outstanding").
@CHECK
if (!N("noun",2))
fail();
if (copulaq(N(2)))
fail();
@POST
fixnphead(2);
group(3,3,"_adjc");
@RULES
_xNIL <-
_xWILD [plus match=(_det _pro _quan _num _xNUM _adj _noun)]
_xALPHA
_adj # 04/25/10 AM.
_xWILD [one lookahead fail=(_xALPHA _adj _noun)]
@@
_xNIL <-
_xWILD [plus match=(_det _pro _quan _num _xNUM _adj _noun)]
_xALPHA
_adj # 04/25/10 AM.
_xEND
@@
# how many alpha
@POST
if (N("noun",2) && N("adj",2))
{
if (N("verb",2))
{
--N("pos num",2);
N("verb",2) = 0; # verb = 0
}
}
else if (N("noun",2))
alphatonoun(2);
else if (N("adj",2))
alphatoadj(2);
@RULES
_xNIL <-
_howmuch [s]
_xALPHA
@@
# when alpha
@PRE
<1,1> varz("pos25 when");
@CHECK
N("pos25 when",1) = 1;
if (N("verb",2))
{
if (vconjq(N(2),"-ing")
|| vconjq(N(2),"-en"))
fail();
}
@POST
if (N("verb",2))
{
--N("pos num",2);
N("verb",2) = 0; # verb = 0
}
alphaunambigred(2);
@RULES
_xNIL <-
when [s]
_xALPHA
@@
# alpha alpha that
@CHECK
if (!N("verb",2))
fail();
if (!vconjq(N(2),"-ed"))
fail();
@POST
alphatoverb(2,"active","VBD");
@RULES
_xNIL <-
_xALPHA
_xALPHA
that [s lookahead]
@@
# verb worth
# Copied here. #
@POST
L("tmp2") = N(2);
group(2,2,"_prep");
pncopyvars(L("tmp2"),N(2));
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
worth
_xWILD [one lookahead match=(_qEOS _xEND \, )]
@@
# alpha $
#@POST
# if (N("verb",1))
# {
# if (vconjq(N(1),"-edn"))
# alphatoverb(1,0,0);
# }
# else if (N("pos num",1) == 2
# && N("noun",1) && N("adj",1))
# fixnphead(1);
#@RULES
#_xNIL <-
# _xALPHA
# _xWILD [one match=(_xEND)]
# @@
# alpha alpha
@CHECK
if (!N("noun",2))
fail();
if (N("adj",2) || N("verb",2))
fail();
if (!N("adj",1) || !N("verb",1))
fail();
if (N("pos num",1) != 2)
fail();
if (!vconjq(N(1),"-edn"))
fail();
@POST
alphatonoun(2);
@RULES
_xNIL <-
_xALPHA
_xALPHA
@@
# Note: exceptions are run on clauses.
# Note: eg, "the ship he runs is shoddy"
# alpha be
@CHECK
if (!N("noun",2))
fail();
if (plural(N(2))) # 04/22/07 AM.
fail();
@POST
fixnphead(2);
@RULES
_xNIL <-
_xWILD [one fail=(_pro _np)]
_xALPHA
_be [s lookahead]
@@
# adj num
@POST
L("tmp2") = N(2);
if (!N(3))
{
group(2,2,"_adj");
pncopyvars(L("tmp2"),N(2));
chpos(N(2),"CD");
}
else
{
if (!N("mypos",3))
chpos(N(3),"POS");
chpos(N(2),"CD");
group(2,3,"_adj");
}
@RULES
_xNIL <-
_adj
_xNUM
_aposS [opt]
@@
@PRE
<1,1> var("verb");
<1,1> varz("noun"); # 04/20/07 AM.
@CHECK
# Require prepositional/phrasal verb.
S("num") = phrprepverbq(N(1),N(2));
if (!S("num"))
fail();
@POST
alphatoverb(1,0,0);
@RULES
_xNIL <-
_xALPHA
to [s]
@@
# noun list. #
# noun , alpha , alpha and alpha noun
@PRE
<3,3> var("noun");
<5,5> var("noun");
<8,8> var("noun");
@POST
alphatonoun(3);
alphatonoun(5);
alphatonoun(8);
group(3,5,"_noun"); # Collapse some of this...
@RULES
_xNIL <-
_noun
\,
_xALPHA
\,
_xALPHA
\, [opt]
_conj
_xALPHA
_noun [lookahead]
@@
# while.
# Note: while as a verb is specialized, ignoring for now.
@CHECK
if (N("mypos",1))
fail();
@POST
chpos(N(1),"IN");
@RULES
_xNIL <-
while [s except=(_noun _prep)]
@@
# past num
@POST
L("tmp1") = N(1);
group(1,1,"_num");
pncopyvars(L("tmp1"),N(1));
chpos(N(1),"JJ");
@RULES
_xNIL <-
past
_xWILD [one lookahead match=(_num _quan _xNUM)]
@@
# dqan
# det noun conj noun prep
@POST
if (N("date",2) || N("date",4))
L("date") = 1;
group(2,4,"_noun");
if (L("date"))
N("date",2) = 1;
@RULES
_xNIL <-
_xWILD [one match=(_det)]
_noun
_conj
_noun
_xWILD [one lookahead match=(_prep)]
@@
# Note: special verbs.
# beginning next
@CHECK
if (!N("noun",1) && !N("verb",1))
fail();
@POST
alphatoverb(2,"active","VBG"); # Conform Treebank.
group(2,3,"_prep"); # Treat as a complex preposition.
@RULES
_xNIL <-
_xALPHA
_xWILD [one match=(starting beginning commencing ending
)]
_prep [opt]
_xWILD [one lookahead match=(next last)]
@@
# noun , alpha $
@PRE
<3,3> var("noun");
@POST
fixnphead(3);
@RULES
_xNIL <-
_noun
\,
_xALPHA
_xWILD [one lookahead match=(_dbldash _xEND)]
@@
# alpha to be
@PRE
<1,1> var("verb");
<1,1> varz("noun");
@CHECK
if (!vconjq(N(1),"-en"))
fail();
@POST
alphatoverb(1,"passive","VBN");
@RULES
_xNIL <-
_xALPHA
to [s lookahead]
_be [s]
@@
# noun and noun alpha
@CHECK
if (!N("noun",4))
fail();
if (!plural(N(4)))
fail();
@POST
alphatonoun(4);
@RULES
_xNIL <-
_noun
_conj
_noun
_xALPHA
@@
# noun alpha of
# noun alpha prep
@PRE
<2,2> var("adj");
@CHECK
if (!plural(N(1)))
fail();
@POST
alphatoadj(2);
group(2,2,"_adjc");
@RULES
_xNIL <-
_noun
_xALPHA
of [s lookahead]
@@
# noun alpha prep
@PRE
<2,2> var("adj");
<2,2> var("adv");
<2,2> vareq("pos num",2);
@CHECK
if (!plural(N(1)))
fail();
@POST
# Prefer adv, but may need some list of preferences
# for post-np cases like these.
alphatoadv(2);
@RULES
_xNIL <-
_noun
_xALPHA
_prep [lookahead]
@@
# alpha of
@PRE
<1,1> var("noun");
<1,1> var("verb");
<1,1> varz("adj");
@CHECK
if (phrprepverbq(N(1),N(2)))
fail();
@POST
fixnphead(1);
@RULES
_xNIL <-
_xALPHA
of [s lookahead]
@@
# det num
@POST
if (N("num",2) == 1)
N("mypos",2) = "NN";
else
N("mypos",2) = "NNS";
pnrename(N(2),"_noun"); # num -> noun
@RULES
_xNIL <-
_det
_num
_xWILD [one lookahead fail=(_xALPHA _det _quan _num _xNUM
_adj _adjc _noun _fnword)]
@@
# one alpha
# num alpha
@PRE
<3,3> var("verb");
@POST
alphatoverb(3,0,0);
@RULES
_xNIL <-
_xWILD [one match=(_dbldash)]
_num
_xALPHA
_xWILD [one lookahead match=(_det _pro)]
@@
# num that
# one that
@PRE
<1,1> varz("mypos");
@POST
pnrename(N(1),"_np"); # one -> np
chpos(N(1),"NN"); # one/NN
@RULES
_xNIL <-
one [s]
that [s lookahead]
@@
# if alpha
@CHECK
if (!N("verb",2))
fail();
if (!vconjq(N(2),"inf"))
fail();
@POST
--N("pos num",2);
N("verb",2) = 0; # verb = 0
alphaunambigred(2);
@RULES
_xNIL <-
if [s]
_xALPHA
@@
# , alpha adj
# , alpha noun
@PRE
<2,2> var("noun");
<2,2> var("adj");
<2,2> vareq("pos num",2);
@POST
fixnpnonhead(2);
@RULES
_xNIL <-
\,
_xALPHA
_xWILD [one lookahead match=(_adj _noun)]
@@
# noun , alpha adj
# dqan , alpha adj
@PRE
<3,3> var("verb");
<3,3> varz("adj");
@POST
alphatovg(3,0,0);
@RULES
_xNIL <-
_xWILD [one match=(_noun _np)] ### (1)
\, ### (2)
_xALPHA ### (3)
_adj [lookahead] ### (4)
@@
# conj alpha adj
@PRE
<3,3> var("noun");
<3,3> var("verb");
<3,3> vareq("pos num",2);
@POST
alphatoverb(3,0,0);
@RULES
_xNIL <-
_conj
_adv [star]
_xALPHA
_adj [lookahead]
@@
# num alpha $
@CHECK
if (!N("noun",2))
fail();
if (!singular(N(2)))
fail();
if (N("num",1) > 1900 && N("num",1) < 2015)
succeed();
fail();
@POST
fixnphead(2);
@RULES
_xNIL <-
_xNUM
_xALPHA
_xEND
@@
# get verb
@PRE
<1,1> vareq("stem","get");
@CHECK
if (!vconjq(N(2),"-en"))
fail();
@POST
pnrename(N(1),"_be");
L("tmp1") = N(1);
group(1,1,"_verb");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
_verb
_verb
@@
# get alpha
@PRE
<1,1> vareq("stem","get");
<2,2> var("verb");
@CHECK
if (!vconjq(N(2),"-en"))
fail();
@POST
alphatoverb(2,"passive","VBN");
pnrename(N(1),"_be");
L("tmp1") = N(1);
group(1,1,"_verb");
pncopyvars(L("tmp1"),N(1));
@RULES
_xNIL <-
_verb
_xALPHA
@@
# det adj verb alpha
@PRE
<2,2> var("cap");
<5,5> var("noun");
@CHECK
if (!vconjq(N(4),"-en"))
fail();
if (N("mass",5))
fail();
if (plural(N(5)))
fail();
@POST
pnrename(N(4),"_adj"); # verb -> adj
fixnphead(5);
@RULES
_xNIL <-
_det
_noun [opt]
_adj
_verb
_xALPHA
_xWILD [one lookahead match=(_dbldash _xEND)]
@@
# verb so alpha
@PRE
<3,3> var("adj");
@CHECK
if (!copulaq(N(1)))
fail();
@POST
pnrename(N(2),"_adv");
chpos(N(2),"RB"); # so/RB
alphatoadj(3);
@RULES
_xNIL <-
_verb
so [s]
_xALPHA
@@
# before $
@PRE
<1,1> varz("pos25 before $");
@POST
N("pos25 before $",1) = 1;
chpos(N(1),"RB"); # before/RB
pnrename(N(1),"_adv");
@RULES
_xNIL <-
before [s]
_xWILD [one match=(_qEOS _xEND _dbldash \, )]
@@
# unworkable by ...
# , adj by
@POST
group(2,2,"_adjc");
N("ellipted-copula",2) = 1;
@RULES
_xNIL <-
\,
_adj
by [s lookahead]
@@
# pro alpha $
@POST
if (N("verb",2) && vconjq(N(2),"inf"))
alphatovg(2,"active","VBP");
@RULES
_xNIL <-
us [s]
_xALPHA
_xEND
@@
# , adj ,
@POST
excise(3,3);
excise(1,1);
@RULES
_xNIL <-
\,
_adj
\,
@@
# who noun verb
@PRE
<3,3> varz("mypos");
@CHECK
if (!vconjq(N(3),"-ed"))
fail();
@POST
chpos(N(3),"VBD");
@RULES
_xNIL <-
_whword [s]
_xWILD [one match=(_noun _np)]
_verb
@@
# Note: Too simple and stupid. Need more context. #
# noun verb
#@PRE
#<2,2> varz("mypos");
#@CHECK
# if (!vconjq(N(2),"inf"))
# fail();
#@POST
# chpos(N(2),"VBP");
#@RULES
#_xNIL <-
# _noun
# _verb
# @@
# prep both alpha
@CHECK
if (!N("noun",3) && !N("adj",3))
fail();
@POST
if (N("noun",3) && plural(N(3)))
fixnphead(3);
else if (N("adj",3))
alphatoadj(3);
@RULES
_xNIL <-
of [s]
both [s]
_xALPHA
@@
# before alpha noun
@PRE
<2,2> var("verb");
@CHECK
if (!vconjq(N(2),"-ing"))
fail();
@POST
alphatovg(2,"active","VBG");
@RULES
_xNIL <-
before [s]
_xALPHA
_xWILD [one lookahead match=(_noun _np _det _quan _adj
_num _xNUM )]
@@
# before
# Note: Try simple approach here.
@PRE
<1,1> varz("mypos");
@POST
chpos(N(1),"IN"); # before/IN
# pnrename(N(1),"_prep");
@RULES
_xNIL <- before [s] @@
# verb alpha alpha prep
# Ex: was still well above
@CHECK
if (N(2))
{
if (!N("adv",2))
fail();
}
@POST
alphatoadv(3);
alphatoadv(2);
@RULES
_xNIL <-
_verb
_xALPHA [opt]
well
_prep [lookahead]
@@
# alpha alpha dqan
# ving ving dqan
@PRE
<1,1> var("noun");
<2,2> var("verb");
@CHECK
if (!N("verb",1))
fail();
if (!vconjq(N(1),"-ing") || !vconjq(N(2),"-ing"))
fail();
@POST
alphatoverb(2,"active","VBG");
@RULES
_xNIL <-
_xALPHA
_xALPHA
_xWILD [one match=(_det _pro _quan _num _xNUM _np)]
@@
# conj alpha , modal $
@PRE
<3,3> var("noun");
@POST
fixnphead(3);
@RULES
_xNIL <-
_conj
_adv [star]
_xALPHA
\,
_modal
_xEND
@@
# alpha pro
@PRE
<2,2> var("noun");
<3,3> var("prosubj");
@POST
fixnphead(2);
@RULES
_xNIL <-
_xSTART
_xALPHA
_pro [lookahead]
@@
_xNIL <-
_xWILD [one match=(_dbldash)]
_xALPHA
_pro [lookahead]
@@
# alpha pro
@PRE
<1,1> var("verb");
<1,1> varz("adj");
@POST
alphatoverb(1,0,0);
@RULES
_xNIL <-
_xALPHA
_adv [star]
_xWILD [s one match=(me him them us)] # Some _proObj
@@
# prep num alpha _conj
@CHECK
N("num") = num(N("$text",2));
if (N("num") < 1900 || N("num") > 2015)
fail();
if (N("noun",2) && plural(N(2)))
fail();
if (N("verb",2) && vconjq(N(2),"-s"))
fail();
@POST
alphatonoun(2);
chpos(N(2),"CD"); # num/CD.
L("tmp2") = N(2);
nountonp(2,1);
@RULES
_xNIL <-
_prep
_xNUM
_xALPHA [lookahead]
_conj
@@
# prep num alpha
@PRE
<4,4> var("adj");
@POST
alphatoadj(4);
@RULES
_xNIL <-
_prep
_xWILD [star match=(_det _pro)]
_xWILD [plus match=(_quan _num _xNUM)]
_xALPHA
_xWILD [one lookahead match=(_adj _noun)]
@@
# noun verb to alpha alpha
# np vg to alpha alpha
@PRE
<4,4> var("verb");
<5,5> varz("verb");
@CHECK
if (!vconjq(N(4),"inf"))
fail();
@POST
alphatovg(4,"active","VB");
@RULES
_xNIL <-
_xWILD [one match=(_noun _np)]
_xWILD [one match=(_verb _vg)]
to [s]
_xALPHA
_xALPHA [lookahead]
@@
# noun alpha to verb
# np alpha to vg
@PRE
<2,2> var("verb");
@CHECK
if (!verbfeat(N(2),"T3"))
fail();
@POST
alphatoverb(2,0,"VBP");
@RULES
_xNIL <-
_xWILD [one match=(_noun _np _pro)]
_xALPHA
to [s lookahead]
_xWILD [one match=(_verb _vg _modal)]
@@
# noun alpha to alpha
@PRE
<2,2> var("verb");
<4,4> var("verb");
@CHECK
if (!verbfeat(N(2),"T3"))
fail();
if (!vconjq(N(4),"inf"))
fail();
@POST
alphatoverb(4,"active","VB");
alphatoverb(2,"active","VBP");
@RULES
_xNIL <-
_xWILD [one match=(_noun _np)]
_xALPHA
to [s]
_xALPHA
@@
# det alpha , alpha
@PRE
<2,2> var("adj");
<4,4> var("adj");
@POST
fixnpnonhead(2);
@RULES
_xNIL <-
_det
_xALPHA
\, [lookahead]
_xALPHA
@@
# verb prep dqa alpha alpha by
# vg prep dqa alpha alpha by
@PRE
<7,7> var("noun");
@CHECK
if (!N("noun",6) && !N("adj",6))
fail();
if (!vconjq(N(1),"-en"))
fail();
@POST
if (!N("voice",1))
{
if (pnname(N(1)) == "_vg")
fixvg(N(1),"passive","VBN");
else
fixverb(N(1),"passive","VBN");
}
fixnphead(7);
fixnpnonhead(6);
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_prep
_xWILD [star match=(_det _pro)]
_xWILD [star match=(_quan _num _xNUM)]
_adj [star]
_xALPHA
_xALPHA
by [s lookahead]
@@
# verb by alpha alpha alpha conj
# vg by alpha alpha alpha conj
# verb prep alpha alpha alpha conj
@PRE
<2,2> vareq("stem","by");
@POST
if (N("noun",3) && plural(N(3)))
fixnphead(3);
else if (!N(4)) # One alpha
{
}
else if (!N(5)) # Two alphas
{
if (N("noun",4) && plural(N(4)))
fixnphead(4);
}
else # Three alphas
{
if (N("noun",4) && plural(N(4)))
fixnphead(4);
else if (N("noun",5) && plural(N(5)))
{
fixnphead(5);
if (N("adj",4) || N("noun",4))
fixnpnonhead(4);
}
}
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_prep
_xALPHA
_xALPHA [opt]
_xALPHA [opt]
_xWILD [one lookahead match=(_conj)]
@@
# conj alpha alpha alpha ,
@PRE
<2,2> var("noun");
<3,3> var("verb");
@CHECK
if (!plural(N(2)))
fail();
if (!vconjq(N(3),"-ing"))
fail();
@POST
alphatovg(3,"active","VBG");
fixnphead(2);
@RULES
_xNIL <-
_xWILD [plus match=(_conj \, )]
_xALPHA
_xALPHA
_xALPHA [star]
_xWILD [one lookahead match=( \, _conj)]
@@
# alpha prep
# Note: Looks too broad. #
@PRE
<1,1> varz("proposs");
<2,2> var("verb");
@CHECK
S("num") = phrprepverbq(N(2),N(3));
if (!S("num"))
fail();
if (vconjq(N(2),"inf") || vconjq(N(3),"-s"))
fail();
@POST
if (vconjq(N(2),"-edn")) # ambig
L("pos") = 0;
else if (vconjq(N(2),"-ed"))
L("pos") = "VBD";
else if (vconjq(N(2),"-en"))
L("pos") = "VBD";
else
L("pos") = "VBP";
alphatoverb(2,0,L("pos"));
if (!N("mypos",3))
{
if (N(4))
chpos(N(3),"IN"); # prep/IN
else if (S("num") == 1 # PHRASAL.
|| S("num") == 3)
chpos(N(3),"RP"); # prep/RP
else
chpos(N(3),"IN"); # prep/IN
}
@RULES
_xNIL <-
_xWILD [one fail=( \, _det )]
_xALPHA
_prep [lookahead]
_prep [opt]
@@
# dqan time
# Note: Idiom
@PRE
<6,6> var("cap");
@POST
N("ellipted-that",6) = 1;
if (literal(N(5)))
fixnphead(5);
L("tmp5") = N(5);
group(1,5,"_np");
pncopyvars(L("tmp5"),N(1));
clearpos(N(1),1,1);
# Really it's equivalent to "when"!
group(1,1,"_whword");
N("stem",1) = "when";
group(1,1,"_fnword");
@RULES
_xNIL <-
_xWILD [plus match=(_det _pro)] ### (1)
_xWILD [star match=(_quan _num _xNUM)] ### (2)
_adj [star] ### (3)
_noun [star] ### (4)
time [s] ### (5)
_noun [lookahead] ### (6)
@@
# dqan
# Note: plain dqan
@PRE
<1,1> varz("prosubj");
<1,1> varz("proobj");
# Only possessive pronoun, if _pro.
@POST
dqaninfo(1,2,3,4);
groupnp();
@RULES
_xNIL <-
_xWILD [plus match=(_det _pro)]
_xWILD [star match=(_quan _num _xNUM)]
_adj [star]
_noun [plus]
_xWILD [one lookahead fail=(_xALPHA _noun _conj \, _aposS _aposX _adj)]
@@
# prep alpha conj
@PRE
<1,1> varne("stem","to");
<2,2> var("noun");
@CHECK
if (N("verb",2))
{
if (vconjq(N(2),"-ing"))
fail(); # Ambig.
}
@POST
fixnphead(2);
@RULES
_xNIL <-
_prep
_xALPHA
_conj [lookahead]
@@
# to dqan alpha $
@PRE
<1,1> vareq("stem","to");
@CHECK
dqaninfo(2,3,4,5);
if (!numbersagree(S("first"),N(6)))
fail();
@POST
fixnphead(6);
@RULES
_xNIL <-
_prep
_xWILD [opt match=(_det _pro)]
_xWILD [star match=(_quan _num _xNUM)]
_adj [star]
_noun [plus]
_xALPHA
_xWILD [one lookahead match=(_dbldash _xEND)]
@@
# where noun alpha*
@PRE
<3,3> var("verb");
@CHECK
# Todo: nvagree.
if (plural(N(2)))
{
if (!vconjq(N(3),"inf") && !vconjq(N(3),"-ed"))
fail();
}
else
{
if (!vconjq(N(3),"-s") && !vconjq(N(3),"-ed"))
fail();
}
@POST
alphatoverb(3,"active","VBP");
@RULES
_xNIL <-
where [s]
_noun
_xALPHA
_xALPHA [star]
_xWILD [one lookahead match=(_fnword _prep)]
@@
# noun conj alpha , adj
# Note: Part of a complex noun or list.
@PRE
<3,3> var("noun");
@POST
fixnphead(3);
@RULES
_xNIL <-
_xWILD [one match=(_noun _np)]
_conj
_xALPHA
\, [lookahead]
_xWILD [one match=(_adj _adjc)]
@@
# which alpha alpha adj
@PRE
<2,2> var("verb");
@CHECK
if (N("adv",2) && N("verb",3))
fail(); # Another interp.
if (!N("noun",3) && !N("adj",3))
fail();
if (vconjq(N(2),"-ing"))
fail();
@POST
alphatovg(2,0,"VBP");
@RULES
_xNIL <-
which [s]
_xALPHA
_xALPHA [lookahead]
@@
# pro alpha conj
@PRE
<2,2> var("noun");
@POST
fixnphead(2);
@RULES
_xNIL <-
_proPoss [s]
_xALPHA
_conj [lookahead]
_xWILD [one match=(_np _det _quan _num _xNUM)]
@@
# verb alpha conj alpha
@PRE
<3,3> varz("pos25 v-a-conj-a");
@POST
N("pos25 v-a-conj-a",3) = 1;
if ((N("noun",2) || N("adj",2)) && !N("verb",2))
{
if (!N("adj",4))
alphatonoun(2);
}
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_xALPHA
_conj [lookahead]
_xALPHA
@@
# verb to alpha
# be to alpha
# have to alpha
@PRE
<3,3> var("verb");
<3,3> varz("noun");
@CHECK
if (N("stem",1) != "be" && N("stem",1) != "have")
fail();
if (!vconjq(N(3),"inf"))
fail();
@POST
alphatoverb(3,"active","VB");
@RULES
_xNIL <-
_xWILD [one match=(_verb _vg)]
_prep
_xALPHA
@@
# Hard-wired development set item.
# (Not to raise score, but because every error is reviewed
# over and over.)
@PRE
<4,4> var("verb");
@CHECK
if (!vconjq(N(4),"-ed"))
fail();
@POST
alphatovg(4,"active","VBD");
@RULES
_xNIL <-
I [s]
say [s]
_dblquote
_xALPHA
_noun
_dblquote
@@
###########################
# JOBDESC #
# Ex: ^ Designs and oversees # JOBDESC #
# ^ cap and verb
# Todo: agreement among the two verbs.
@PRE
<2,2> var("verb"); # Can be a verb.
@POST
alphatovg(2,"active",0);
@RULES
_xNIL <-
_xSTART
_xCAP
_xWILD [one lookahead match=(_conj)]
_xWILD [one match=(_verb _vg)]
@@
|
@CODE
# Created in pr_laddr.txt
#fileout("addr.txt");
prlit("addr.txt","\n");
prlit("addr.txt","ZONE ADDRESSPARTS\n");
prlit("addr.txt","-----------------\n");
@@CODE
# @NODES _ROOT #
@PATH _ROOT # 10/19/99 AM.
# Print out the total count of vars in each line.
@POST
prlit("addr.txt", "zone count=");
# fprintnvar("addr.txt", "addressParts", 1);
"addr.txt" << N("addressParts",1);
prlit("addr.txt", "\n");
@RULES
_xNIL <- _xANY @@
|
@NODES _LINE
@POST
X("concept") = N("$text",2);
@RULES
_xNIL <-
\" ### (1)
_xALPHA ### (2)
\" ### (3)
_xEND ### (4)
@@
|
# Build an apple kb with color and weight
@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
addstrval(G("apple"),"have","color");
# Apple's color is red
addstrval(G("apple"),"color","red");
# Apple's color is also green and yellow
addstrval(G("apple"),"color","green and yellow");
The code creates a KB like this:
The following code accesses the KB's attributes and values:
# Find apple's attribute list
G("attrList") = findattrs(G("apple"));
# Find the list of values of the first attribute
G("valList") = attrvals(G("attrList"));
# print out the first attribute's name and value
if(attrname(G("attrList"))){
"output.txt" << "1) first attribute of apple is: " << attrname(G("attrList")) << "\n";
"output.txt" << "2) first value of that attribute is: " << getstrval(G("valList")) << "\n";}
# get the next attribute
G("nextAttr") = nextattr(G("attrList"));
if(attrname(nextattr(G("attrList"))))
"output.txt" << "3) next attribute of apple is: " << attrname(G("nextAttr")) << "\n";
# get the list of values of the second attribute
G("valList") = attrvals(G("nextAttr"));
# print the first value's name
"output.txt" << "4) first value of that attribute is: " << getstrval(G("valList")) << "\n";
# print the second value of the second attribute
"output.txt" << "5) second value of that attribute is: " << getstrval(nextval(G("valList"))) << "\n";
The output looks like this:
|
# Execute commands in a knowledge base command file (.KB file)
@CODE
take("e:\\apps\\tester\\companies.kb");
take("\\data\\myadditions.kb"); # Starts from G("$apppath"),
project folder.
@@CODE
where the companies.kb file might contain the following:
add hier "concept" "company"
add hier "concept" "company"
"ford"
add hier "concept" "company
"gm"
....
quit |
@POST
rfanodes(2, path)
single()
@RULES
_PATH [base] <- _soPATH _NONLIT [star] _eoPATH [opt] @@
|
@POST
rfanodes(2, "nodes")
single()
@RULES
_NODES [base] <- _soNODES [s] _NONLIT [star] _eoNODES [s opt] @@
@POST
rfanodes(2, "path")
single()
@RULES
_PATH [base] <- _soPATH [s] _NONLIT [star] _eoPATH [s opt] @@
@POST
rfanodes(2, "multi")
single()
@RULES
_MULTI [base] <- _soMULTI [s] _NONLIT [star] _eoMULTI [s opt] @@
# Need a check action to flag an error if _endMark found at last elt.
@POST
oldgroup(2,2, "_NLPPP") # An NLP++ region.
singler(1,3)
@RULES
_PRES [base unsealed] <-
_soPRE [s]
_xWILD [fail=(_endMark _startMark)]
_eoPRE [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
# Need a check action to flag an error if _endMark found at last elt.
@POST
oldgroup(2,2, "_NLPPP") # An NLP++ region.
singler(1,3)
@RULES
_CHECKS [base unsealed] <-
_soCHECK [s]
_xWILD [fail=(_endMark _startMark)]
_eoCHECK [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
# Need a check action to flag an error if _endMark found at last elt.
@POST
oldgroup(2,2, "_NLPPP") # An NLP++ region.
singler(1,3)
@RULES
_POSTS [base unsealed] <-
_soPOST [s]
_xWILD [fail=(_endMark _startMark)]
_eoPOST [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
# Need a check action to flag an error if _endMark found at last elt.
@POST
singler(1,3)
@RULES
_RULES [base unsealed] <-
_soRULES [s]
_xWILD [fail=(_endMark _startMark)]
_eoRULES [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
# NEW REGION! FOR RUNNING CODE BEFORE SOMETHING (like @nodes).
# Need a check action to flag an error if _endMark found at last elt.
@POST
oldgroup(2,2, "_NLPPP") # An NLP++ region.
singler(1,3)
@RULES
_INI [base unsealed] <-
_soINI [s]
_xWILD [fail=(_endMark _startMark)]
_eoINI [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
# NEW REGION! FOR RUNNING CODE AFTER SOMETHING (like @nodes).
# Need a check action to flag an error if _endMark found at last elt.
@POST
oldgroup(2,2, "_NLPPP") # An NLP++ region.
singler(1,3)
@RULES
_FIN [base unsealed] <-
_soFIN [s]
_xWILD [fail=(_endMark _startMark)]
_eoFIN [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
# Need a check action to flag an error if _endMark found at last elt.
@POST
oldgroup(2,2, "_NLPPP") # An NLP++ region.
setbase(2,"true")
singler(1,3)
@RULES
_CODE [base unsealed] <-
_soCODE [s]
_xWILD [fail=(_endMark _startMark)]
_eoCODE [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
@POST
oldgroup(2,2, "_NLPPP") # An NLP++ region.
setbase(2,"true")
singler(1,3)
@RULES
_DECL [base unsealed] <-
_soDECL [s]
_xWILD [fail=(_endMark _startMark)]
_eoDECL [s opt]
_xWILD [opt lookahead match=(_endMark _startMark)]
@@
|
@CODE
L("hello") = 0;
@@CODE
@NODES _sent
@PRE
<1,1> lowercase();
@CHECK
if (N("ne type",2))
fail();
@POST
L("tmp") = lasteltnode(3);
# if (pnvar(L("tmp"),"apos-s"))
# {
# S("apos-s") = 1;
# group(2,3,"_adj");
# }
# else
group(2,3,"_noun");
pncopyvars(L("tmp"),N(2));
@RULES
_xNIL <-
_xWILD [s one match=(_xALPHA _xPUNCT _xNUM)]
_xWILD [one match=(_xCAP _caps)]
_xWILD [s plus match=(_xCAP _caps \- )]
@@
@POST
L("tmp") = lasteltnode(3);
# if (pnvar(L("tmp"),"apos-s"))
# {
# group(2,3,"_adj");
# N("apos-s",2) = 1;
# }
# else
group(2,3,"_noun");
pncopyvars(L("tmp"),N(2));
@RULES
_xNIL <-
_xSTART
_abbr [s]
_xWILD [s plus match=(_xCAP _caps \- )]
@@
@CHECK
if (!N("cap",3))
fail();
if (N("cap",1) || N("cap",5))
fail(); # Need bigger handler...
@POST
L("tmp4") = lasteltnode(4);
group(2,4,"_caps");
group(2,2,"_noun");
pncopyvars(L("tmp4"),N(2));
chpos(N(2),"NP");
@RULES
_xNIL <-
_xANY
_xWILD [s plus match=(_xCAP _caps)]
_xANY
_xWILD [s plus match=(_xCAP _caps)]
_xANY
@@
_xNIL <-
_xSTART
_xWILD [s plus match=(_xCAP _caps)]
_xANY
_xWILD [s plus match=(_xCAP _caps)]
_xANY
@@
@CHECK
if (!N("unknown"))
fail();
if (N("cap"))
fail(); # Already handled by caps.
@POST
L("tmp1") = N(1);
group(1,1,"_caps");
# if (pnvar(L("tmp1"),"apos-s"))
# group(1,1,"_adj");
# else
group(1,1,"_noun");
pncopyvars(L("tmp1"),N(1));
N("cap") = 1;
N("ne") = 1;
# Some domain semantics.
L("lc") = strtolower(N("$text"));
if (finddictattr(L("lc"),"persname"))
{
N("sem") = "person";
N("ne type") = "person";
N("ne type conf") = 70;
}
@RULES
_xNIL <-
_xWILD [s one match=(_xCAP) except=(_np)]
@@
@PRE
<1,1> lowercase();
<3,3> lowercase();
@CHECK
if (N("pos num",2) > 0)
fail();
@POST
L("tmp2") = N(2);
group(2,2,"_caps");
# if (pnvar(L("tmp2"),"apos-s"))
# group(2,2,"_adj");
# else
group(2,2,"_noun");
pncopyvars(L("tmp2"),N(2));
chpos(N(2),"NP");
N("cap",2) = 1;
@RULES
_xNIL <-
_xWILD [s one match=(_xALPHA _xPUNCT _xNUM)]
_xWILD [one match=(_xCAP _abbr)]
_xWILD [s one lookahead match=(_xALPHA _xPUNCT _xNUM _xEND)]
@@
# alpha name
@POST
group(1,1,"_name");
group(1,1,"_noun");
@RULES
_xNIL <-
_xALPHA
_name [s]
@@
#
@CHECK
if (!N("glom",2) || !N("cap",2))
fail();
if (!N("ne",1))
fail();
@POST
L("tmp1") = N(1);
group(2,3,"_caps");
group(2,2,"_noun");
N("cap",2) = 1;
L("ne type") = pnvar(L("tmp1"),"ne type");
if (L("ne type") == "person")
{
N("ne",2) = 1;
N("ne type",2) = "person";
N("ne type conf",2) = 50;
N("stem",2) = N("$text",2);
N("sem",2) = "person";
registerpersnames(N("$text",2));
}
# Assign POS.
@RULES
_xNIL <-
_noun
_noun
_xCAP [plus]
_xANY [lookahead]
@@
|
@CODE
L("hello") = 0;
@@CODE
@NODES _sent
@POST
group(1,2,"_clause");
setunsealed(1,"true"); # 07/10/12 AM.
@RULES
_xNIL <-
_clausestart [opt]
_xWILD [plus fail=(\, _fnword _qEOS _dbldash \" _dblquote _clause _clausestart _clausesep)]
_xWILD [plus lookahead match=(\, _fnword _qEOS _dbldash \" _dblquote _clause
_clausestart _clausesep _xEND)]
@@
@POST
group(1,1,"_clause");
setunsealed(1,"true"); # 07/10/12 AM.
@RULES
_xNIL <-
_clausestart
@@
|
@DECL
########
# FUNC: DOMVNN
# SUBJ: Query semantics for VNN clause.
# EX: "Is Smith an author?"
########
domvnn(
L("clause"),
L("vg"),
L("np1"),
L("np2")
)
{
if (!L("clause") || !L("vg") || !L("np1") || !L("np2"))
return;
L("sem vg") = nodesem(L("vg"));
L("sem np1") = nodesem(L("np1"));
L("sem np2") = nodesem(L("np2"));
#"sem.txt" << L("sem vg")
# << "," << L("sem np1")
# << "," << L("sem np2")
# << "\n";
# be X author
if (L("sem vg") != "be")
return;
if (L("sem np2") == "author")
{
# Case where np1 is a name.
# Case where np1 is undetermined or not a known item.
# (Case of one cap, two caps, etc. Caps patterns...)
# Try
# select * from author where auth_last_name='x';
L("nm") = pnvar(L("np1"),"$text");
L("table") = "author";
L("field") = "auth_last_name";
"cmd.txt"
<< "SELECT * FROM "
<< L("table")
<< " WHERE "
<< L("field")
<< " = '"
<< L("nm")
<< "';"
<< "\n"
;
}
}
@CODE
L("hello") = 0;
@@CODE
|
@CODE
# Simplified since tutorials were recorded
G("person") = getconcept(findroot(),"person");
G("sentences") = getconcept(findroot(),"sentences");
@@CODE |
@PATH _ROOT _equation _split
@POST
addEquationToLabel(X("name",2),N("$text"));
X("split",2) = 1;
@RULES
_xNIL <-
_equation [s]
@@
|
@PATH _ROOT _headerZone
@POST
excise(1,1);
noop();
@RULES
_xNIL <-
_xBLANK [s] ### (1)
@@
|
@NODES _LINE
@PRE
<1,1> cap();
@RULES
# Ex: E-mail:
_emailHeader <- E [s] \- [s] mail [s] \: [s] @@
@RULES
# Ex: e-mail:
_emailHeader <- e [s] \- [s] mail [s] \: [s] @@
@PRE
<1,1> cap();
@RULES
# Ex: Email:
_emailHeader <- Email [s] \: [s] @@
@RULES
# Ex: email:
_emailHeader <- email [s] \: [s] @@
@PRE
<1,1> cap();
<3,3> cap();
@RULES
# Ex: Mail\_To\_:
_emailHeader <- Mail [s] _xWHITE [star s] To [s] _xWHITE [star s] \: [s] @@
@RULES
# Ex: mailto:
_emailHeader <- mailto [s] \: [s] @@
|
Subsets and Splits