Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions importer/wikipedia/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var genericName = regexp.MustCompile(`(?i)^(theorem|lemma|corollary|proposition|
var labelName = regexp.MustCompile(`(?i)^(axiom|theorem|lemma|corollary|proposition|claim|conjecture|definition|fact|step|case|rule|property|observation|remark|example|exercise|problem|condition|assumption|hypothesis)s? ([0-9]+[a-z]?|[A-Z]|[IVX]+)(\.[0-9]+)*$`)

// headingPrefix matches a heading that names a part of the text about an item and not the item, such as "Precise statement of the Adyan–Rabin theorem" or "History: the lemma that is not Burnside's".
var headingPrefix = regexp.MustCompile(`(?i)^(proof of|disproof of|disproved|variants? of|interpretations? (of|via)|relations? (with|to)|extension to include|incompatibility with|modern approach|general formulas|general statement|particular values|analytic criteria|geometry of|conjectures? (on|of)|criterion for|degree of|classical integral|extended|weaker|stronger|original|history|accuracy|an?|theorems?|importance|sharpness|via|equivalence|connections|explicit|formulas?|identity group|another|alternative|connection|derivation|equivalent forms|from|comparison|relationship|relation to|validity|an introduction|theorems proved|precise statement|formal statement|statements?|definitions?|examples?|applications?|consequences|corollary|corollaries|involving|proofs?|outline|sketch|overview|generali[sz]ations?|properties|results|facts|motivation|background|introduction|some|other|further|basic|main|key)\b`)
var headingPrefix = regexp.MustCompile(`(?i)^(characteri[sz]ations?|equivalent formulations|proof of|disproof of|disproved|variants? of|interpretations? (of|via)|relations? (with|to)|extension to include|incompatibility with|modern approach|general formulas|general statement|particular values|analytic criteria|geometry of|conjectures? (on|of)|criterion for|degree of|classical integral|extended|weaker|stronger|original|history|accuracy|an?|theorems?|importance|sharpness|via|equivalence|connections|explicit|formulas?|identity group|another|alternative|connection|derivation|equivalent forms|from|comparison|relationship|relation to|validity|an introduction|theorems proved|precise statement|formal statement|statements?|definitions?|examples?|applications?|consequences|corollary|corollaries|involving|proofs?|outline|sketch|overview|generali[sz]ations?|properties|results|facts|motivation|background|introduction|some|other|further|basic|main|key)\b`)

// pluralTail matches a heading that names a group of items, such as "Freudenthal-Hopf theorems".
var pluralTail = regexp.MustCompile(`(?i)\b(theorems|results|facts|properties|lemmas|formulas|formulae|conjectures|identities|axioms|inequalities|relations|criteria|propositions|principles|primes|graphs)$`)
Expand Down Expand Up @@ -141,7 +141,7 @@ var otherName = regexp.MustCompile(`(?i)\([^)]*\b(theorem|lemma|formula|identity
// pluralWord matches a list entry that is one word in the plural, as "Lattices". The entry names a group of items.
var pluralWord = regexp.MustCompile(`^[A-Z][a-z]+s$`)

var oddName = regexp.MustCompile(`[?"#]|^'|'$|\s\([0-9]{4}\)$|\s\([A-Z]{2,6}\)$|-$| / `)
var oddName = regexp.MustCompile(`\(or |[?"#]|^'|'$|\s\([0-9]{4}\)$|\s\([A-Z]{2,6}\)$|-$| / `)

// questionHead matches a name that is a question, as "How many unit distances".
var questionHead = regexp.MustCompile(`^(How|Can|Are|Is|Does|Do|What|Which|Why|When)\b`)
Expand Down Expand Up @@ -632,6 +632,10 @@ func displayName(m *inventory.Mention) string {
if m.Cue == "lead" && !strings.Contains(m.ID, "#") && m.NativeID != Name(m.NativeID) && inventory.NameKey(m.Name) == inventory.NameKey(Name(m.NativeID)) {
return m.NativeID
}
// A heading such as "The Routh criterion" names the item with "The", and the node takes "Routh criterion".
if rest, ok := strings.CutPrefix(m.Name, "The "); ok && m.Cue != "lead" && m.Cue != "term" && rest != "" && unicode.IsUpper([]rune(rest)[0]) {
return rest
}
if m.Cue != "term" || m.Name == "" {
return m.Name
}
Expand Down
14 changes: 14 additions & 0 deletions importer/wikipedia/adopt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ func TestWhyName(t *testing.T) {
{"list-entry", "Lattices", true},
{"named-heading", "Identity / neutral elements", true},
{"named-heading", "Variants of Wilson's theorem", true},
{"named-heading", "Characterization by a convolution identity", true},
{"named-heading", "Equivalent formulations of locality axiom", true},
{"list-entry", "Root (or zero) of a polynomial", true},
{"named-heading", "Bhargava's approach to the composition law", true},
{"named-heading", "Interpretation via the Chinese Remainder Theorem", true},
{"named-heading", "Extension to include the Goldbach conjecture", true},
Expand Down Expand Up @@ -457,6 +460,17 @@ func TestDisplayNameQualifier(t *testing.T) {
}
}

func TestDisplayNameThe(t *testing.T) {
m := &inventory.Mention{ID: "wikipedia://en/3#o4", Cue: "named-heading", Name: "The Routh criterion"}
if got := displayName(m); got != "Routh criterion" {
t.Errorf("got %q", got)
}
m = &inventory.Mention{ID: "wikipedia://en/4", Cue: "lead", Name: "The Pirates of Penzance"}
if got := displayName(m); got != "The Pirates of Penzance" {
t.Errorf("got %q", got)
}
}

func TestDropNotes(t *testing.T) {
notes := map[string]string{"n3": "Serre (1977).", "o6": "See Logic programming."}
for in, want := range map[string]string{
Expand Down
Loading