mova-articles
The definite articles in place names, for the languages of the 79 editions (76 base codes: es-ES and es-419, pt-PT
and pt-BR, zh-CN and zh-TW share theirs). A site that writes «the weather in …» in many languages uses it to join a
preposition to a place name as each language writes it, and to capitalize a name at the start of a title. No
dependencies; deterministic; every rule cites its source (an academy, a style guide or a grammar) in Lang::source.
Languages
| kind | what it means | languages |
|---|---|---|
InName | the article belongs to the name and is written in it | en, fr, ca, it, es, gl, nl, ar, ga, cy, mt |
Contextual | the sentence adds the article; the cited name has none | pt, de, el, hu, af, lb |
Suffixed | the article is a suffix; the name is cited without it | ro, sq, sv, da, nb, is, bg, mk, eu, hy, am |
Unsplit | an article exists but cannot be told from the spelling | he |
None | no definite article in place names | tl, ha, yo and 44 more (LANGS; Dryer 2013, WALS chapter 37) |
API
model(code) -> Lang: the language's kind, full and elided forms, suffixes, casing, contractions and source; an edition code reaches its base (es-419→es), an unknown code gets an empty model.split(code, name) -> (article, bare)andseparator(article): the language's own article only, witharticle + separator(article) + bare == name; «Los Angeles» in English and «Den Haag» in German are not split.contract(code, prep, name) -> Option<String>: the preposition joined as the language writes it inside a sentence;Nonefor Irish, whose contractions mutate the noun.sentence_initial(code, name): the name at the start of a sentence or a title (ca «el Caire» → «El Caire»).in_sentence(code, name): the name inside a sentence, its article in the language's casing (it «Il Cairo» → «il Cairo», ca «El Caire» → «el Caire»).check_name(code, lang_name, main, evidence, forms, borrowed) -> Vec<Flag>: review flags of one name against the model and the language's Wikipedia title or Wikidata label of the same place (Evidence):foreign_article,elision,suffixed_form,contextual_article,article_missing,article_extra,article_differs,casing,forms_differ(FLAGS). A flag is a question for a reviewer, not a refusal.
Rules worth knowing
- Catalan (IEC, Ortografia catalana §4.2; Gramàtica §13.2): the article is lowercase inside a sentence (el Caire, l'Havana, la Haia) and a/de/per contract with el, els (al Caire, del Caire, pel Caire); la, l', les do not.
- French (Imprimerie nationale, Lexique; Le Bon Usage §587): the article takes a capital (Le Caire, La Haye); à/de contract with le, les (au Caire, du Havre); La and L' do not (à La Haye).
- Italian (Serianni IV.3, IV.79): a capital in the name cited alone, lowercase in running text and in the articulated prepositions (del Cairo, all'Aia, nella Spezia).
- Spanish (RAE-ASALE, Ortografía §4.2.4.6; DPD s.v. el §1.2): the article is part of the name and is not contracted in writing: «de El Cairo», «a El Salvador», though «del Cairo» is spoken.
- Portuguese (Cunha and Cintra, ch. 11): names are cited without the article (Cairo, Porto); the sentence adds
it (do Cairo, no Porto). The gender and the usage are not in the name, so
contract("pt-BR", "de", "Cairo")gives «de Cairo»; a name written with its article («o Cairo») contracts («do Cairo»). - Galician (RAG, Normas §3.1): the article takes a capital (A Coruña) and contracts lowercase (da Coruña).
- Arabic (Wright I §§344-345): al- is attached; bi-/ka-/wa-/fa- join it (بالقاهرة), li- drops the alif (للقاهرة).
- Welsh and Maltese: y/yr becomes 'r after a vowel (i'r Fenni); Maltese il- assimilates to the sun letters and fuses with fi/bi/ta (fil-Kajr, tar-Rabat).
Examples
use mova_articles::{contract, sentence_initial, split};
assert_eq!(contract("ca", "a", "el Caire").as_deref(), Some("al Caire"));
assert_eq!(contract("fr", "à", "Le Caire").as_deref(), Some("au Caire"));
assert_eq!(contract("fr", "à", "La Haye").as_deref(), Some("à La Haye"));
assert_eq!(contract("it", "di", "L'Aia").as_deref(), Some("dell'Aia"));
assert_eq!(contract("es-ES", "de", "El Cairo").as_deref(), Some("de El Cairo"));
assert_eq!(contract("ar", "ب", "القاهرة").as_deref(), Some("بالقاهرة"));
assert_eq!(sentence_initial("ca", "el Caire"), "El Caire");
assert_eq!(split("ca", "l'Havana"), ("l'".to_string(), "Havana".to_string()));
Limits
Gender is not known, so Italian il/lo/la and Catalan el/la are not chosen, only their elision is checked; an aspirated h (fr «Le Havre», «La Haye») allows both forms; Catalan «la» before an unstressed i/u is not checked; Irish contractions are not modeled; Greek σε + article and German im/zum need the case and the gender a cited name does not carry; Wikipedia titles start with a capital by software, so casing is checked against the convention, never against a title.
Run
cargo test --release --offline -p mova-articles
Code: the Elamur Cosmic License (Elamur Cosmic License at the repo root).
This page in Markdown https://md.mova.elamur.ai/free/en/docs/tools/articles/