警告 # 1 : 包括英语维基词典在内的所有维基词典实际上都有包含每种语言中的每个单词的目标,所以如果你只是简单地使用上面的 API 调用,你就会知道你所询问的单词至少是一种语言中的单词,但不一定是英语中的单词。 < a href = “ http://en.Wiktionary.org/w/API.php? action = query & amp; title = dicare”rel = “ noReferrer”> http://en.Wiktionary.org/w/API.php?action=query&titles=dicare
Caveat #2: Perhaps a redirect exists from one word to another word. It might be from an alternative spelling, but it might be from an error of some kind. The API call above will not differentiate between a redirect and an article: http://en.wiktionary.org/w/api.php?action=query&titles=profilemetry
function parsePronunciationLine(line) {
let val
let type
line.replace(/\{\{\s*a\s*\|UK\s*\}\}\s*\{\{IPA\|\/?([^\/\|]+)\/?\|lang=en\}\}/, (_, $1) => {
val = $1
type = 'uk'
})
line.replace(/\{\{\s*a\s*\|US\s*\}\}\s*\{\{IPA\|\/?([^\/\|]+)\/?\|lang=en\}\}/, (_, $1) => {
val = $1
type = 'us'
})
line.replace(/\{\{enPR|[^\}]+\}\},?\s*\{\{IPA\|\/?([^\/\|]+)\/?\|lang=en}}/, (_, $1) => {
val = $1
type = 'us'
})
line.replace(/\{\{a|GA\}\},?\s*\{\{IPA\|\/?([^\/\|]+)\/?\|lang=en}}/, (_, $1) => {
val = $1
type = 'ga'
})
line.replace(/\{\{a|GA\}\},?.+\{\{IPA\|\/?([^\/\|]+)\/?\|lang=en}}/, (_, $1) => {
val = $1
type = 'ga'
})
// \{\{a|GA}} \{\{IPA|/ˈhæpi/|lang=en}}
// * \{\{a|RP}} \{\{IPA|/pliːz/|lang=en}}
// * \{\{a|GA}} \{\{enPR|plēz}}, \{\{IPA|/pliz/|[pʰliz]|lang=en}}
if (!val)
return
return { val, type }
}
function parseEtymologyPiece(piece) {
let parts = piece.split('|')
parts.shift() // The first one is ignored.
let ls = []
if (langs[parts[0]]) {
ls.push(parts.shift())
}
if (langs[parts[0]]) {
ls.push(parts.shift())
}
let l = ls.pop()
let t = parts.shift()
return [ l, t ]
// \{\{inh|en|enm|poisoun}}
// \{\{m|enm|poyson}}
// \{\{der|en|la|pōtio|pōtio, pōtiōnis|t=drink, a draught, a poisonous draught, a potion}}
// \{\{m|la|pōtō|t=I drink}}
// \{\{der|en|enm|happy||fortunate, happy}}
// \{\{cog|is|heppinn||lucky}}
}