module // Requires Prelude string pattern Verb = [Optional["NEG+"], "VB" | "MD" | "BE" | "HV" | "DO", "P" | "D" | "I" | ""] NPSubj = ["NP-SBJ", ...] end pattern V = {String[Verb], ...} Subj = {String[NPSubj], ...} end let IsCode = fn [x] -> case x of {{"CODE", ...}, ...} -> True Any -> False IsLatin = fn [x] -> case x of {{"LATIN", ...}, Any} -> True Any -> False IsFrag = fn [x] -> case x of {{"FRAG", ...}, Any} -> True Any -> False IsSubject = fn [phrase] -> case phrase of {String["NP-SBJ", ...], ...} -> True Any -> False FixDollarEmendment = fn [x] -> case x of String["$", rest : ...] -> rest y : Any -> y ReadAndClean! = fn [fileName] -> (do ms <- ReadBracketed![fileName] Return![ MapAll[FixDollarEmendment, Remove[IsFrag, Remove[IsLatin, Remove[IsCode, ms]]] ] ]) Condense = fn [phrases] -> Map[First, phrases] SubjectType = fn [phrase] -> case phrase of // Look for (... (NP-SBJ* ... (N ...) ...) ...) {ManyShortest[Any], {String["NP-SBJ", ...], ManyShortest[Any], n : {String[Optional[ManyShortest1[Any], "+"], "N", ...], ...}, ...}, ...} -> {"N", n} // Look for (... (NP-SBJ (PRO ...) ...) ...) // But be careful of (NP-SBJ (PRO$ my) (N widget)) {ManyShortest[Any], {String["NP-SBJ", ...], ManyShortest[Any], pro : {"PRO" | "P", ...}, ...}, ... } -> {"PRO", pro} {ManyShortest[Any], {String["NP-SBJ", ...], ManyShortest[Any], det : {String["D", Optional["+", ...]], ...}, ...}, ... } -> {"D", det} {ManyShortest[Any], {String["NP-SBJ", ...], ManyShortest[Any], q : {"Q", ...}, ...}, ... } -> {"Q", q} {ManyShortest[Any], {String["NP-SBJ", ...], {String["CP", ...], ...}, ...}, ... } -> "CP" {ManyShortest[Any], {String["NP-SBJ", ...], ManyShortest[Any], ex : {"EX", ...}}, ... } -> {"EX", ex} {ManyShortest[Any], {String["NP-SBJ", ...], ManyShortest[Any], {"ONE", ...}, {"PP", {"P", "of"}, ...}, ... }, ...} -> "ONE-of" {ManyShortest[Any], {String["NP-SBJ", ...], t : "*con*" | "*pro*" | "*exp*"}, ... } -> t Any -> "Subject?" end