Skip to content

Latest commit

 

History

History

person

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wtf-plugin-person
a plugin for wtf_wikipedia

npm install wtf-plugin-person

A plugin that finds birth date, birth place, and death date information for people, in its various places in a wikipedia article.

const wtf = require('wtf_wikipedia')
wtf.extend(require('wtf-plugin-person'))
;(async () => {
  await wtf.fetch('David Phillips (entrepreneur)').birthDate()
  // {year: 1964, month:null, date:null}
})()
<script src="https://unpkg.com/wtf_wikipedia"></script>
<script src="https://unpkg.com/wtf-plugin-person"></script>
<script defer>
  wtf.plugin(window.wtfPerson)
  wtf.fetch('Elvis Presley').then((doc) => {
    console.log(doc.deathPlace())
    // Memphis, Tennessee, U.S.
  })
</script>

Notes:

  • This library assumes that every article you give it is about a person. You may want to use it in conjunction with wtf-plugin-classify to ensure that a page is first about a person, and not a place, or musical group:
wtf.fetch('Billy Elliot').then((doc) => {
  let res = doc.classify() // 'CreativeWork/Play'
  if (res.root === 'Person') {
    console.log(doc.birthPlace())
  }
})
  • For inaccurate dates, if the date is a range, finds the average rounded down; otherwise finds the minimum.

.birthDate()

returns month, year and date properties (also originalDate if the date is inaccurate), or a null response

  • looks at various person-infoboxes, like Infobox officeholder or Infobox ice hockey player
  • looks at first-sentence parentheses, like 'Wayne Douglas Gretzky CC (/ˈɡrɛtski/; born January 26, 1961) is a ...'
  • looks at category information, like 'Category:1933 births'

.birthPlace()

returns a string - and a wikipedia article title, if possible

  • looks at various person infoboxes
  • looks at category information, like 'Category:People from Geneva'

.isAlive()

returns true, false, or null for unknown result.

  • looks for a .deathDate() or .deathPlace() result
  • looks at category information, like Category:Dead people
  • looks at template information, like {{WikiProject Biography|living=yes }}

.deathDate()

same as .birthDate()

.deathPlace()

same as .birthPlace()

work-in-progress

MIT