Skip to main content

narrative_graph/heuristic/
pack.rs

1//! The closed vocabularies one language needs, gathered into one named unit.
2//!
3//! Every list here was a `const` sitting beside the code that read it, in four
4//! different files. Gathering them makes the English assumption explicit rather
5//! than implicit: what a second language must supply is exactly this struct,
6//! and nothing outside it.
7//!
8//! IMPORTANT: a pack is vocabulary, not strategy. Three assumptions live in the
9//! code that reads a pack and cannot be moved into one:
10//!
11//! - Capitalization is the entity signal (`extract_capitalized_entities`). A
12//!   language that capitalizes every noun, or none, needs a different detector,
13//!   not a different word list.
14//! - A possessive is a clitic on the possessor, read left to right.
15//! - Sentence-final `.`/`!`/`?` terminate, and a lowercase continuation does not.
16//!
17//! A second pack is therefore only enough for a language that shares those
18//! three. Chinese shares none of them and has a reader of its own
19//! (`chinese.rs`) rather than a pack.
20
21use super::cooccurrence::base;
22
23mod names;
24mod phrases;
25
26/// A verb-phrase rule: a marker that must appear between the two mentions,
27/// optionally a second one, and the relation that follows from both.
28pub struct VerbRule {
29    /// The token that licenses the relation. Leading space where the rule
30    /// wants a word boundary in front of it.
31    pub marker: &'static str,
32    /// A second token the same window must also carry, as "work" needs "at".
33    pub also: Option<&'static str>,
34    /// A token that reverses subject and object, as passive voice does.
35    pub passive_marker: Option<&'static str>,
36    pub relation: &'static str,
37    pub rule: &'static str,
38    pub base: f32,
39}
40
41/// What a mention must be for a phrase rule to apply to it.
42#[derive(Debug, Clone, Copy, PartialEq, Eq)]
43pub enum Slot {
44    /// Anything not positively known to be a place, organization or thing.
45    Person,
46    /// Anything not positively known to be a person.
47    Place,
48    /// Positively a place or organization by its own words.
49    Venue,
50    /// No constraint.
51    Any,
52}
53
54/// A phrase rule: the whole text between two mentions, once fillers and
55/// trailing determiners are peeled off, equals one of `phrases`. See
56/// `pack/phrases.rs`.
57pub struct PhraseRule {
58    pub phrases: &'static [&'static str],
59    pub relation: &'static str,
60    pub rule: &'static str,
61    pub base: f32,
62    /// What the earlier mention must be, and the later one. Read in text order,
63    /// independent of `passive`.
64    pub subject: Slot,
65    pub object: Slot,
66    /// The relation's subject is the later mention.
67    pub passive: bool,
68}
69
70/// Everything the pipeline reads as vocabulary for one language.
71pub 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    /// The pronoun list cut by what it agrees with. IMPORTANT: every entry
78    /// must also appear in `pronouns`, which is what decides whether a word is
79    /// a pronoun at all; these only say what kind.
80    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    /// Titles that settle the bearer's gender. A subset of `honorifics`:
85    /// "dr", "captain" and "professor" are titles and settle nothing.
86    pub masculine_titles: &'static [&'static str],
87    pub feminine_titles: &'static [&'static str],
88    /// Words whose presence in front of a capitalized run marks it as a common
89    /// noun phrase rather than a personal name.
90    pub determiners: &'static [&'static str],
91    /// Pronouns that name the speaker or the listener rather than anyone in
92    /// the story. IMPORTANT: these are never mentions. "I" is capitalized in
93    /// every sentence of first-person narration, and a graph node called `i`
94    /// names whoever happens to be talking.
95    pub deictic_pronouns: &'static [&'static str],
96    /// Verbs of a dialogue tag ("said Diana", "Heathcliff asked"): the name
97    /// next to one, outside quotation marks, is the speaker of the paragraph.
98    pub speech_verbs: &'static [&'static str],
99    /// Speech verbs that carry on the previous speaker's turn ("continued my
100    /// master"), whoever the tag goes on to name.
101    pub resuming_verbs: &'static [&'static str],
102    /// The pronouns that stand in subject position. IMPORTANT: only these are
103    /// read as evidence about the name in front of them. An object or
104    /// possessive pronoun after a name usually names someone else — "Archer
105    /// looked at her" is about two people — so learning from one records the
106    /// opposite of what the sentence says.
107    pub subject_pronouns: &'static [&'static str],
108    /// Prepositions that take a place and essentially never take a person.
109    /// "to" and "from" are absent: both take people constantly.
110    pub locative_prepositions: &'static [&'static str],
111    /// Names of times rather than of people.
112    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    /// Relations whose object admits exactly one subject, so two different
120    /// subjects asserted over one object contradict each other.
121    pub single_filler_relations: &'static [&'static str],
122    /// A negator that attaches as a suffix rather than standing as a word.
123    pub negation_clitic: &'static str,
124    /// The word whose infinitive complement suspends the event it names.
125    pub infinitive_marker: &'static str,
126    /// The clitic marking the mention before it as a possessor.
127    pub possessive_clitic: &'static str,
128    /// The link word in an "of" genitive: "the sister of Marco".
129    pub genitive_link: &'static str,
130    /// The conjunction that closes a possessed noun phrase.
131    pub phrase_conjunction: &'static str,
132    /// The opener of a relative clause about the preceding mention.
133    pub relative_opener: &'static str,
134    /// Rules read directly from the text between two mentions.
135    pub verb_rules: &'static [VerbRule],
136    /// Rules read from the same text once `relative_opener` is present.
137    pub relative_rules: &'static [VerbRule],
138    /// Exact-phrase rules between two mentions.
139    pub phrase_rules: &'static [PhraseRule],
140    /// Words peeled from the front of the text between mentions before a
141    /// phrase rule is compared.
142    pub phrase_fillers: &'static [&'static str],
143    /// Words peeled from the end of it.
144    pub phrase_trailers: &'static [&'static str],
145    /// Last words of a multi-word mention that name a place.
146    pub place_heads: &'static [&'static str],
147    /// Last words of a multi-word mention that name an organization.
148    pub org_heads: &'static [&'static str],
149    /// First words of a multi-word mention that name a place.
150    pub place_leads: &'static [&'static str],
151    /// Whole names that are places.
152    pub place_names: &'static [&'static str],
153    /// Whole names that are capitalized things: languages, faiths, address terms.
154    pub thing_names: &'static [&'static str],
155    /// Possessive determiners that stand for a possessor named elsewhere.
156    pub possessive_pronouns: &'static [&'static str],
157    /// First-person pronouns, resolved only when the caller names the narrator.
158    pub first_person_pronouns: &'static [&'static str],
159    /// Plural relational nouns for "x and y are <plural>", as (noun, relation, base).
160    pub plural_nouns: &'static [(&'static str, &'static str, f32)],
161    /// The copulas that introduce a plural noun or adjective.
162    pub plural_copulas: &'static [&'static str],
163    /// Words allowed between the copula and a plural noun: "are old friends".
164    pub plural_modifiers: &'static [&'static str],
165    /// Closed-class words that may follow an object pronoun, closing the phrase
166    /// it ends: "met her at the station".
167    pub object_followers: &'static [&'static str],
168    /// Words that may follow a possessed relational noun without making it a
169    /// modifier of a later noun: "Marco's student for two terms".
170    pub possessive_tails: &'static [&'static str],
171}
172
173/// The pack the pipeline runs with. Selecting a different one is a caller-facing
174/// decision that waits on a second pack existing; nothing here presumes English
175/// is the only possible value.
176pub 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/// Words that are capitalized at the start of a sentence by position alone.
354///
355/// IMPORTANT: a capitalized run becomes one mention, so "But Elena" normalizes
356/// to `but_elena` and never unifies with `elena` elsewhere in the text. That
357/// silently splits a character into two graph nodes, and narrative prose opens
358/// sentences this way constantly.
359///
360/// Membership is restricted to words that cannot also be a given name in that
361/// position: "May", "Will", "Grace", "June", "Faith" and "Summer" are all
362/// names and are deliberately absent, because dropping a real mention costs
363/// more than keeping a malformed one.
364///
365/// The pronouns `extract_pronouns` owns are listed here too. A capitalized
366/// pronoun otherwise becomes a second mention at the same offsets as the
367/// resolved one, and `she` as a graph node names nobody.
368#[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
383/// Lowercase particles that belong to the name they sit inside.
384///
385/// IMPORTANT: a particle only continues a run already open. "Bourgh" is what
386/// "Lady Catherine de Bourgh" normalized to before this list existed, which
387/// names a surname shared with "Sir Lewis de Bourgh" rather than either person.
388/// A particle may not open a mention, because the same words open ordinary
389/// clauses ("van" rarely, "bin" and "af" never, but "du" and "della" occur in
390/// quoted French and Italian).
391///
392/// English "of" is deliberately absent. It is the only candidate that also
393/// appears in `SENTENCE_OPENERS` and as the link text `of_genitive_noun`
394/// matches, so admitting it would fold "the Duchess of Devonshire" into one
395/// mention and change the shape of mentions already measured in
396/// `docs/EVALUATION.md`, while doing nothing for a title whose noun is
397/// lowercase and therefore closes the run before "of" is reached.
398const 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/// Titles and ranks that precede a name and are not part of the identity.
404///
405/// IMPORTANT: this cuts differently from both lists above. A particle joins a
406/// run, an opener is dropped at position 0 only, and a title is capitalized,
407/// real, and correctly part of the surface form; it just must not be part of
408/// the identity, or "the Right Honourable Lady Catherine de Bourgh" can never
409/// unify with any shorter mention of her.
410///
411/// Entries are bare: `.` is a separator in `extract_capitalized_entities`, so
412/// the run already reads "Mrs Bennet" and a "mrs." entry would never match.
413///
414/// Membership is restricted to words that do not also do relational or naming
415/// work. "Father", "Mother", "Sister" and "Master" are titles in address but
416/// heads of the relational lexicon `find_relation_pattern` matches; "Major",
417/// "General" and "President" are common nouns. "Grace" is excluded for the
418/// reason "May" and "June" are excluded above: it is a given name, and "His
419/// Grace" needs no entry, since `strip_honorifics` keeps a title standing in
420/// front of a single name word.
421#[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
431/// Words that form a compounded style only in front of another title. Alone
432/// they are ordinary adjectives, so they are stripped only when an entry of
433/// `HONORIFICS` follows.
434const HONORIFIC_QUALIFIERS: &[&str] = &["right", "most", "very"];
435
436/// Pronouns that can stand for a mention made earlier in the same sentence.
437const PRONOUNS: &[&str] = &[
438    "he", "she", "they", "him", "her", "them", "his", "their", "it",
439];
440
441/// Words that end in a period without ending a sentence.
442const ABBREVIATIONS: &[&str] = &[
443    // Personal and professional titles
444    "mr", "mrs", "ms", "dr", "prof", "rev", "fr", "sr", "jr", "st", "hon", "msgr",
445    // Military and civil ranks
446    "lt", "capt", "col", "gen", "sgt", "maj", "adm", "cmdr", "gov", "sen", "rep", "det", "insp",
447    "supt", // Common Latin and editorial abbreviations
448    "etc", "vs", "viz", "cf", "al", "ibid", "approx", "est", "min", "max",
449    // Organizational and address abbreviations
450    "inc", "ltd", "co", "corp", "dept", "univ", "mt", "ft", "ave", "blvd", "no", "vol", "ed", "pp",
451    "fig",
452];
453
454/// Relational nouns recognized in a possessive, as (noun, relation, base
455/// confidence). Every entry reads "X is Y's <noun>", giving relation(X, Y).
456///
457/// The relation is named explicitly rather than derived from the noun so a
458/// noun can share a label with a verb rule: "Elena is Marco's mentor" and
459/// "Elena mentors Marco" are the same fact and must not produce two edge
460/// types. The rule name stays `possessive-<noun>-pattern`, so attribution
461/// remains per-noun. Matching is whole-word, so entries are order-independent.
462const POSSESSIVE_NOUNS: &[(&str, &str, f32)] = &[
463    // Hyphenated nouns first: a stem ("wife") also matches inside them, and the
464    // first noun that heads the phrase wins.
465    (
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    // Kinship and role: the possessive states the relation outright.
488    ("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    // Shares its label with verb-mentor-pattern: the same fact, said two ways.
552    ("mentor", "mentors", base::POSSESSIVE_FACTUAL),
553    // Social stance: same shape, weaker claim.
554    ("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
563/// Plural nouns for "x and y are <plural>". "married" is an adjective, listed
564/// because it states the same fact the same way.
565const 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
586/// Links that let the possessive be read as a statement about the subject.
587///
588/// IMPORTANT: matched against the whole trimmed text between the two mentions,
589/// never as a substring. "Elena visited Marco's sister" names a third person,
590/// and "is not", "was never", "could be" and "believed ... was" each deny,
591/// hedge or attribute the claim rather than making it. Every one of those
592/// contains a copula; none of them is one.
593///
594/// The plural copulas are absent. "Dev and Elena are Marco's cousins" has two
595/// subjects and the pair loop sees one of them, so extracting it would be half
596/// right by construction; the lexicon also matches whole-word and would have
597/// to carry "cousins" to reach the phrase at all.
598const POSSESSIVE_COPULAS: &[&str] = &["is", "was"];
599
600/// Pre-nominal modifiers that may stand between an appositive comma and the
601/// possessor, as in "Bob Spicer, old Mrs. Mingott's father".
602///
603/// IMPORTANT: closed class, and it holds no verb, no conjunction and no
604/// relative pronoun. "Elena, who visited Marco's sister" and "Dev, and Marco's
605/// sister" are not appositions, and admitting "who" or "and" here would read
606/// both as one.
607#[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
616/// Closed-class words that hold the event open without settling it either way.
617///
618/// IMPORTANT: this is a closed class on purpose. The verbs that suspend a
619/// complement (refuse, hope, intend, pretend) are an open one, and are caught
620/// structurally by the `to`-infinitive instead. "will" is absent because a
621/// future tense asserts.
622///
623/// A suspender outranks a negator: "if Elena is not Marco's sister" settles
624/// nothing, so it is suspended rather than denied. A conditional denial is not
625/// a denial, and reading it as one is how a contradiction check invents a
626/// conflict the text never states.
627const SUSPENDING_WORDS: &[&str] = &[
628    "if", "unless", "whether", "could", "would", "might", "may", "should",
629];
630
631/// Words that deny the event outright. Paired with the `n't` clitic, which is
632/// a suffix rather than a word and is handled beside this list.
633const NEGATORS: &[&str] = &["not", "never", "no", "nor", "neither"];
634
635/// Relations where the object admits one subject and no more.
636///
637/// IMPORTANT: membership is about the world, not about the grammar. A person
638/// has one mother and one father; they may have any number of siblings,
639/// cousins, teachers and enemies, so those are absent. "widow_of" is absent
640/// too: remarriage makes it repeatable over a lifetime, and a manuscript
641/// spanning one is not in error for saying so.
642///
643/// Read with the relation's own direction: an entry reads "X is Y's <noun>",
644/// so the constraint binds the object. Two different people asserted as
645/// `mother_of` one person contradict each other; one person asserted as
646/// `mother_of` two people does not.
647const SINGLE_FILLER_RELATIONS: &[&str] = &["mother_of", "father_of"];
648
649/// Verbs read straight from the text between the mentions.
650///
651/// IMPORTANT: passive voice ("was mentored by") names the mentor second, so the
652/// relation's subject is the later entity, not the earlier one. The leading
653/// space on each marker is the word boundary in front of it; the mention's own
654/// end supplies the one behind.
655const 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
674/// The same verbs inside a relative clause, which puts more text between the
675/// mentions and scores lower for it. The markers carry no leading space: the
676/// relative opener has already supplied the boundary.
677const 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];