valid_parts = ["Abbreviation", "Adjective", "Adverb", "Article", "Cardinal number", "Conjunction", "Determiner", "Interjection", "Noun", "Numeral", "Particle", "Preposition", "Pronoun", "Verb"]
+ edit_link_regex = new RegExp(' ?\\[edit\\] ?')
+
elements.each (i, el) ->
#which tag: el.tagName
if el.tagName is 'H2'
if found
return false # break
part = false # mark us not being in a definition section unless the next section finds a part of speach header
- language = $(el).text().substr 7
+ language = $(el).text().replace(edit_link_regex, '')
if language and el.tagName is 'H3' or el.tagName is 'H4' # eg yak def uses one for english and one for dutch
part = false
- text = $(el).text()
+ text = $(el).text().replace(edit_link_regex, '')
for p in valid_parts
- if text is "[edit] #{p}"
+ if text is "#{p}"
part = p.toLowerCase()
# FIXME break
if part and el.tagName is 'OL'
tdl = extract_wiktionary_definiton data.parse.text['*']
if tdl
show_definition word, tdl[0], tdl[1], tdl[2]
+ else
+ $definition_body.html "Oops, could't find a definition for \"#{word}\"."
else
$definition_body.html "Sorry, couldn't find a definition for \"#{word}\"."
})