3
\$\begingroup\$

Challenge

Write code that, given an English word, outputs the number of syllables it has. Scoring will be determined by a combination of code length and accuracy.

Rules

  • The accuracy of the solution should be measured against this CSV file (which countains syllable counts for all the 52,439 entries in the CMU Pronouncing Dictionary that are also words listed in the SOWPODS Scrabble Dictionary).
  • Entries should accept any word listed in the file and return a numeric value for it; behaviour on other inputs is left undefined. Note that the words listed are all lower-case and between 2 and 15 letters long.
  • The returned syllable count is correct if it corresponds to any of the listed counts for that word. Note that some words have multiple correct syllable counts, which are separated with a '|' in the CSV: eg
resume,2|3
resumed,2
resumes,2|3
resuming,3

Scoring

This is a modified , with the total score being the sum of the code length in bytes and the square of percentage error (which is first rounded to the nearest percent). For example:

  • lambda s:2 has a score of 10 (bytes) + 61*61 (squared % error) = 3731
  • lambda s:sum(s.count(v)for v in "aeiouy") has a score of 41 + 45*45 = 2066.
\$\endgroup\$
4
  • 3
    \$\begingroup\$ Related / possible dupe (difference is the given word-list to test against and scoring formula). I don't have the time to build a test-suite (might do so tomorrow), but I wonder what percentage the regex of that accepted answer would match in the list of this challenge. \$\endgroup\$ Nov 13, 2019 at 14:46
  • \$\begingroup\$ @KevinCruijssen That is quite similar, isn't it? :-( I've tested the top Ruby answer and it scores 86.52%, which gives an overall score of 53 + 13^2 = 222. I can personally do a bit better, but perhaps it's too similar to be of interest. \$\endgroup\$
    – Uri Granta
    Nov 13, 2019 at 15:40
  • \$\begingroup\$ Should I just close it as duplicate? \$\endgroup\$
    – Uri Granta
    Nov 13, 2019 at 15:41
  • 1
    \$\begingroup\$ 175 (75 bytes, 10.44% incorrect words). \$\endgroup\$
    – Grimmy
    Nov 13, 2019 at 17:28

0

Browse other questions tagged or ask your own question.