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>
- 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.
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
orInfobox 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'
returns a string - and a wikipedia article title, if possible
- looks at various person infoboxes
- looks at category information, like
'Category:People from Geneva'
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 }}
same as .birthDate()
same as .birthPlace()
work-in-progress
MIT