1use super::cooccurrence::base;
22
23mod names;
24mod phrases;
25
26pub struct VerbRule {
29 pub marker: &'static str,
32 pub also: Option<&'static str>,
34 pub passive_marker: Option<&'static str>,
36 pub relation: &'static str,
37 pub rule: &'static str,
38 pub base: f32,
39}
40
41#[derive(Debug, Clone, Copy, PartialEq, Eq)]
43pub enum Slot {
44 Person,
46 Place,
48 Venue,
50 Any,
52}
53
54pub struct PhraseRule {
58 pub phrases: &'static [&'static str],
59 pub relation: &'static str,
60 pub rule: &'static str,
61 pub base: f32,
62 pub subject: Slot,
65 pub object: Slot,
66 pub passive: bool,
68}
69
70pub struct LanguagePack {
72 pub sentence_openers: &'static [&'static str],
73 pub name_particles: &'static [&'static str],
74 pub honorifics: &'static [&'static str],
75 pub honorific_qualifiers: &'static [&'static str],
76 pub pronouns: &'static [&'static str],
77 pub masculine_pronouns: &'static [&'static str],
81 pub feminine_pronouns: &'static [&'static str],
82 pub neuter_pronouns: &'static [&'static str],
83 pub plural_pronouns: &'static [&'static str],
84 pub masculine_titles: &'static [&'static str],
87 pub feminine_titles: &'static [&'static str],
88 pub determiners: &'static [&'static str],
91 pub deictic_pronouns: &'static [&'static str],
96 pub speech_verbs: &'static [&'static str],
99 pub resuming_verbs: &'static [&'static str],
102 pub subject_pronouns: &'static [&'static str],
108 pub locative_prepositions: &'static [&'static str],
111 pub temporal_names: &'static [&'static str],
113 pub abbreviations: &'static [&'static str],
114 pub possessive_nouns: &'static [(&'static str, &'static str, f32)],
115 pub possessive_copulas: &'static [&'static str],
116 pub appositive_modifiers: &'static [&'static str],
117 pub suspending_words: &'static [&'static str],
118 pub negators: &'static [&'static str],
119 pub single_filler_relations: &'static [&'static str],
122 pub negation_clitic: &'static str,
124 pub infinitive_marker: &'static str,
126 pub possessive_clitic: &'static str,
128 pub genitive_link: &'static str,
130 pub phrase_conjunction: &'static str,
132 pub relative_opener: &'static str,
134 pub verb_rules: &'static [VerbRule],
136 pub relative_rules: &'static [VerbRule],
138 pub phrase_rules: &'static [PhraseRule],
140 pub phrase_fillers: &'static [&'static str],
143 pub phrase_trailers: &'static [&'static str],
145 pub place_heads: &'static [&'static str],
147 pub org_heads: &'static [&'static str],
149 pub place_leads: &'static [&'static str],
151 pub place_names: &'static [&'static str],
153 pub thing_names: &'static [&'static str],
155 pub possessive_pronouns: &'static [&'static str],
157 pub first_person_pronouns: &'static [&'static str],
159 pub plural_nouns: &'static [(&'static str, &'static str, f32)],
161 pub plural_copulas: &'static [&'static str],
163 pub plural_modifiers: &'static [&'static str],
165 pub object_followers: &'static [&'static str],
168 pub possessive_tails: &'static [&'static str],
171}
172
173pub static ENGLISH: LanguagePack = LanguagePack {
177 sentence_openers: SENTENCE_OPENERS,
178 name_particles: NAME_PARTICLES,
179 honorifics: HONORIFICS,
180 honorific_qualifiers: HONORIFIC_QUALIFIERS,
181 pronouns: PRONOUNS,
182 masculine_pronouns: &["he", "him", "his"],
183 feminine_pronouns: &["she", "her"],
184 neuter_pronouns: &["it", "its"],
185 plural_pronouns: &["they", "them", "their"],
186 masculine_titles: &["mr", "mister", "sir", "lord"],
187 feminine_titles: &["mrs", "ms", "miss", "dame", "lady"],
188 determiners: &["the", "a", "an"],
189 deictic_pronouns: &[
190 "i",
191 "me",
192 "my",
193 "mine",
194 "myself",
195 "you",
196 "your",
197 "yours",
198 "yourself",
199 "we",
200 "us",
201 "our",
202 "ours",
203 "ourselves",
204 ],
205 resuming_verbs: &["continued", "resumed", "pursued", "persisted"],
206 speech_verbs: &[
207 "said",
208 "says",
209 "asked",
210 "asks",
211 "cried",
212 "cries",
213 "replied",
214 "replies",
215 "answered",
216 "answers",
217 "exclaimed",
218 "exclaims",
219 "shouted",
220 "shouts",
221 "called",
222 "calls",
223 "whispered",
224 "whispers",
225 "continued",
226 "continues",
227 "interrupted",
228 "interrupts",
229 "inquired",
230 "inquires",
231 "demanded",
232 "demands",
233 "returned",
234 "rejoined",
235 "added",
236 "adds",
237 "repeated",
238 "pronounced",
239 "hallooed",
240 "screamed",
241 "muttered",
242 "murmured",
243 "observed",
244 "remarked",
245 "retorted",
246 "sobbed",
247 "snapped",
248 "growled",
249 "laughed",
250 "began",
251 "pleaded",
252 "urged",
253 "insisted",
254 "declared",
255 "resumed",
256 ],
257 subject_pronouns: &["he", "she", "it", "they"],
258 locative_prepositions: &[
259 "at", "in", "near", "into", "within", "upon", "beyond", "outside", "inside", "across",
260 ],
261 temporal_names: &[
262 "january",
263 "february",
264 "march",
265 "april",
266 "june",
267 "july",
268 "august",
269 "september",
270 "october",
271 "november",
272 "december",
273 "monday",
274 "tuesday",
275 "wednesday",
276 "thursday",
277 "friday",
278 "saturday",
279 "sunday",
280 "christmas",
281 "easter",
282 "michaelmas",
283 "lady day",
284 "midsummer",
285 ],
286 abbreviations: ABBREVIATIONS,
287 possessive_nouns: POSSESSIVE_NOUNS,
288 possessive_copulas: POSSESSIVE_COPULAS,
289 appositive_modifiers: APPOSITIVE_MODIFIERS,
290 suspending_words: SUSPENDING_WORDS,
291 negators: NEGATORS,
292 single_filler_relations: SINGLE_FILLER_RELATIONS,
293 negation_clitic: "n't",
294 infinitive_marker: "to",
295 possessive_clitic: "'s",
296 genitive_link: "of",
297 phrase_conjunction: " and ",
298 relative_opener: ", who ",
299 verb_rules: VERB_RULES,
300 relative_rules: RELATIVE_RULES,
301 phrase_rules: phrases::PHRASE_RULES,
302 phrase_fillers: phrases::PHRASE_FILLERS,
303 phrase_trailers: phrases::PHRASE_TRAILERS,
304 place_heads: names::PLACE_HEADS,
305 org_heads: names::ORG_HEADS,
306 place_leads: names::PLACE_LEADS,
307 place_names: names::PLACE_NAMES,
308 thing_names: names::THING_NAMES,
309 possessive_pronouns: &["his", "her", "my", "our"],
310 first_person_pronouns: &["i", "me", "my", "mine", "myself", "our"],
311 plural_nouns: PLURAL_NOUNS,
312 plural_copulas: &["are", "were"],
313 plural_modifiers: &[
314 "close", "longtime", "lifelong", "very", "great", "real", "true",
315 ],
316 object_followers: &[
317 "at",
318 "in",
319 "on",
320 "to",
321 "with",
322 "for",
323 "from",
324 "and",
325 "but",
326 "as",
327 "when",
328 "after",
329 "before",
330 "while",
331 "again",
332 "once",
333 "too",
334 "there",
335 "here",
336 "today",
337 "later",
338 "that",
339 "because",
340 "until",
341 "by",
342 "outside",
343 "inside",
344 "yesterday",
345 "tonight",
346 ],
347 possessive_tails: &[
348 "for", "since", "during", "until", "when", "while", "before", "after", "at", "in", "from",
349 "once", "then", "now", "there", "here", "too", "again", "as", "by", "that", "who",
350 ],
351};
352
353#[rustfmt::skip]
369const SENTENCE_OPENERS: &[&str] = &[
370 "a", "after", "again", "all", "although", "an", "and", "another", "any", "are", "as", "at",
371 "because", "before", "both", "but", "by", "did", "do", "does", "each", "either", "even",
372 "every", "for", "from", "had", "has", "have", "he", "her", "here", "him", "his", "how",
373 "however", "if",
374 "in", "indeed", "instead", "well", "oh", "ah", "yes", "aye", "nay", "hush", "thanks", "hello", "alas", "pray", "dear", "is", "its", "just", "later", "maybe", "meanwhile", "my", "neither",
375 "never", "no", "nor", "not", "now", "of", "often", "on", "once", "only", "or", "our",
376 "perhaps", "since", "so", "some", "sometimes", "soon", "still", "suddenly", "that", "the",
377 "she", "their", "them", "then", "there", "these", "they", "this", "those", "though", "to",
378 "today", "tomorrow",
379 "tonight", "was", "were", "what", "when", "where", "which", "while", "who", "whom", "whose",
380 "why", "with", "yesterday", "yet", "your",
381];
382
383const NAME_PARTICLES: &[&str] = &[
399 "de", "del", "della", "der", "des", "di", "du", "la", "le", "van", "von", "af", "ter", "bin",
400 "ibn", "al", "da", "dos", "das", "y",
401];
402
403#[rustfmt::skip]
422const HONORIFICS: &[&str] = &[
423 "mr", "mrs", "ms", "miss", "mister", "dr", "doctor", "sir", "dame", "lady", "lord",
424 "captain", "capt", "colonel", "col", "reverend", "rev", "professor", "prof",
425 "sergeant", "sgt", "lieutenant", "admiral", "bishop", "cardinal",
426 "judge", "dean", "officer", "detective", "inspector", "senator", "governor", "mayor",
427 "coach", "pastor", "principal", "nurse", "deputy",
428 "hon", "honourable", "honorable",
429];
430
431const HONORIFIC_QUALIFIERS: &[&str] = &["right", "most", "very"];
435
436const PRONOUNS: &[&str] = &[
438 "he", "she", "they", "him", "her", "them", "his", "their", "it",
439];
440
441const ABBREVIATIONS: &[&str] = &[
443 "mr", "mrs", "ms", "dr", "prof", "rev", "fr", "sr", "jr", "st", "hon", "msgr",
445 "lt", "capt", "col", "gen", "sgt", "maj", "adm", "cmdr", "gov", "sen", "rep", "det", "insp",
447 "supt", "etc", "vs", "viz", "cf", "al", "ibid", "approx", "est", "min", "max",
449 "inc", "ltd", "co", "corp", "dept", "univ", "mt", "ft", "ave", "blvd", "no", "vol", "ed", "pp",
451 "fig",
452];
453
454const POSSESSIVE_NOUNS: &[(&str, &str, f32)] = &[
463 (
466 "mother-in-law",
467 "mother_in_law_of",
468 base::POSSESSIVE_FACTUAL,
469 ),
470 (
471 "father-in-law",
472 "father_in_law_of",
473 base::POSSESSIVE_FACTUAL,
474 ),
475 (
476 "sister-in-law",
477 "sister_in_law_of",
478 base::POSSESSIVE_FACTUAL,
479 ),
480 (
481 "brother-in-law",
482 "brother_in_law_of",
483 base::POSSESSIVE_FACTUAL,
484 ),
485 ("ex-wife", "ex_wife_of", base::POSSESSIVE_FACTUAL),
486 ("ex-husband", "ex_husband_of", base::POSSESSIVE_FACTUAL),
487 ("sister", "sister_of", base::POSSESSIVE_FACTUAL),
489 ("brother", "brother_of", base::POSSESSIVE_FACTUAL),
490 ("mother", "mother_of", base::POSSESSIVE_FACTUAL),
491 ("father", "father_of", base::POSSESSIVE_FACTUAL),
492 ("grandmother", "grandmother_of", base::POSSESSIVE_FACTUAL),
493 ("grandfather", "grandfather_of", base::POSSESSIVE_FACTUAL),
494 ("daughter", "daughter_of", base::POSSESSIVE_FACTUAL),
495 ("son", "son_of", base::POSSESSIVE_FACTUAL),
496 ("wife", "wife_of", base::POSSESSIVE_FACTUAL),
497 ("husband", "husband_of", base::POSSESSIVE_FACTUAL),
498 ("cousin", "cousin_of", base::POSSESSIVE_FACTUAL),
499 ("aunt", "aunt_of", base::POSSESSIVE_FACTUAL),
500 ("uncle", "uncle_of", base::POSSESSIVE_FACTUAL),
501 ("niece", "niece_of", base::POSSESSIVE_FACTUAL),
502 ("nephew", "nephew_of", base::POSSESSIVE_FACTUAL),
503 ("widow", "widow_of", base::POSSESSIVE_FACTUAL),
504 ("stepmother", "stepmother_of", base::POSSESSIVE_FACTUAL),
505 ("stepfather", "stepfather_of", base::POSSESSIVE_FACTUAL),
506 ("stepdaughter", "stepdaughter_of", base::POSSESSIVE_FACTUAL),
507 ("stepson", "stepson_of", base::POSSESSIVE_FACTUAL),
508 ("stepsister", "stepsister_of", base::POSSESSIVE_FACTUAL),
509 ("stepbrother", "stepbrother_of", base::POSSESSIVE_FACTUAL),
510 (
511 "granddaughter",
512 "granddaughter_of",
513 base::POSSESSIVE_FACTUAL,
514 ),
515 ("grandson", "grandson_of", base::POSSESSIVE_FACTUAL),
516 ("godmother", "godmother_of", base::POSSESSIVE_FACTUAL),
517 ("godfather", "godfather_of", base::POSSESSIVE_FACTUAL),
518 ("godson", "godson_of", base::POSSESSIVE_FACTUAL),
519 ("goddaughter", "goddaughter_of", base::POSSESSIVE_FACTUAL),
520 ("twin", "twin_of", base::POSSESSIVE_FACTUAL),
521 ("fiance", "fiance_of", base::POSSESSIVE_FACTUAL),
522 ("fiancee", "fiance_of", base::POSSESSIVE_FACTUAL),
523 ("girlfriend", "girlfriend_of", base::POSSESSIVE_FACTUAL),
524 ("boyfriend", "boyfriend_of", base::POSSESSIVE_FACTUAL),
525 ("partner", "partner_of", base::POSSESSIVE_STANCE),
526 ("boss", "boss_of", base::POSSESSIVE_FACTUAL),
527 ("colleague", "colleague_of", base::POSSESSIVE_STANCE),
528 ("coworker", "coworker_of", base::POSSESSIVE_STANCE),
529 ("roommate", "roommate_of", base::POSSESSIVE_STANCE),
530 ("classmate", "classmate_of", base::POSSESSIVE_STANCE),
531 ("neighbor", "neighbor_of", base::POSSESSIVE_STANCE),
532 ("neighbour", "neighbor_of", base::POSSESSIVE_STANCE),
533 ("landlord", "landlord_of", base::POSSESSIVE_FACTUAL),
534 ("tenant", "tenant_of", base::POSSESSIVE_FACTUAL),
535 ("patient", "patient_of", base::POSSESSIVE_FACTUAL),
536 ("doctor", "doctor_of", base::POSSESSIVE_FACTUAL),
537 ("therapist", "therapist_of", base::POSSESSIVE_FACTUAL),
538 ("lawyer", "lawyer_of", base::POSSESSIVE_FACTUAL),
539 ("client", "client_of", base::POSSESSIVE_FACTUAL),
540 ("assistant", "assistant_of", base::POSSESSIVE_FACTUAL),
541 ("sponsor", "sponsor_of", base::POSSESSIVE_FACTUAL),
542 ("ex", "ex_of", base::POSSESSIVE_FACTUAL),
543 ("guardian", "guardian_of", base::POSSESSIVE_FACTUAL),
544 ("employer", "employer_of", base::POSSESSIVE_FACTUAL),
545 ("servant", "servant_of", base::POSSESSIVE_FACTUAL),
546 ("master", "master_of", base::POSSESSIVE_FACTUAL),
547 ("teacher", "teacher_of", base::POSSESSIVE_FACTUAL),
548 ("student", "student_of", base::POSSESSIVE_FACTUAL),
549 ("pupil", "pupil_of", base::POSSESSIVE_FACTUAL),
550 ("apprentice", "apprentice_of", base::POSSESSIVE_FACTUAL),
551 ("mentor", "mentors", base::POSSESSIVE_FACTUAL),
553 ("friend", "friend_of", base::POSSESSIVE_STANCE),
555 ("enemy", "enemy_of", base::POSSESSIVE_STANCE),
556 ("rival", "rival_of", base::POSSESSIVE_STANCE),
557 ("lover", "lover_of", base::POSSESSIVE_STANCE),
558 ("companion", "companion_of", base::POSSESSIVE_STANCE),
559 ("ally", "ally_of", base::POSSESSIVE_STANCE),
560 ("acquaintance", "acquaintance_of", base::POSSESSIVE_STANCE),
561];
562
563const PLURAL_NOUNS: &[(&str, &str, f32)] = &[
566 ("sisters", "sister_of", base::POSSESSIVE_FACTUAL),
567 ("brothers", "brother_of", base::POSSESSIVE_FACTUAL),
568 ("siblings", "sibling_of", base::POSSESSIVE_FACTUAL),
569 ("cousins", "cousin_of", base::POSSESSIVE_FACTUAL),
570 ("twins", "twin_of", base::POSSESSIVE_FACTUAL),
571 ("married", "spouse_of", base::POSSESSIVE_FACTUAL),
572 ("friends", "friend_of", base::POSSESSIVE_STANCE),
573 ("lovers", "lover_of", base::POSSESSIVE_STANCE),
574 ("partners", "partner_of", base::POSSESSIVE_STANCE),
575 ("colleagues", "colleague_of", base::POSSESSIVE_STANCE),
576 ("coworkers", "coworker_of", base::POSSESSIVE_STANCE),
577 ("roommates", "roommate_of", base::POSSESSIVE_STANCE),
578 ("neighbors", "neighbor_of", base::POSSESSIVE_STANCE),
579 ("neighbours", "neighbor_of", base::POSSESSIVE_STANCE),
580 ("classmates", "classmate_of", base::POSSESSIVE_STANCE),
581 ("rivals", "rival_of", base::POSSESSIVE_STANCE),
582 ("enemies", "enemy_of", base::POSSESSIVE_STANCE),
583 ("allies", "ally_of", base::POSSESSIVE_STANCE),
584];
585
586const POSSESSIVE_COPULAS: &[&str] = &["is", "was"];
599
600#[rustfmt::skip]
608const APPOSITIVE_MODIFIERS: &[&str] = &[
609 "the", "a", "an", "this", "that",
610 "his", "her", "their", "its", "my", "our", "your",
611 "old", "young", "little", "poor", "dear", "late", "good",
612 "younger", "older", "elder", "eldest", "youngest", "oldest", "best", "closest", "only",
613 "twin", "adopted", "biological", "favorite", "own", "new",
614];
615
616const SUSPENDING_WORDS: &[&str] = &[
628 "if", "unless", "whether", "could", "would", "might", "may", "should",
629];
630
631const NEGATORS: &[&str] = &["not", "never", "no", "nor", "neither"];
634
635const SINGLE_FILLER_RELATIONS: &[&str] = &["mother_of", "father_of"];
648
649const VERB_RULES: &[VerbRule] = &[
656 VerbRule {
657 marker: " mentor",
658 also: None,
659 passive_marker: Some(" by"),
660 relation: "mentors",
661 rule: "verb-mentor-pattern",
662 base: base::VERB,
663 },
664 VerbRule {
665 marker: " work",
666 also: Some(" at"),
667 passive_marker: None,
668 relation: "works_at",
669 rule: "verb-works-at-pattern",
670 base: base::VERB,
671 },
672];
673
674const RELATIVE_RULES: &[VerbRule] = &[
678 VerbRule {
679 marker: "work",
680 also: Some("at"),
681 passive_marker: None,
682 relation: "works_at",
683 rule: "relative-works-at-pattern",
684 base: base::RELATIVE_CLAUSE,
685 },
686 VerbRule {
687 marker: "mentor",
688 also: None,
689 passive_marker: None,
690 relation: "mentors",
691 rule: "relative-mentor-pattern",
692 base: base::RELATIVE_CLAUSE,
693 },
694];