Counting syllables

3

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.

Uri Granta

Posted 2019-11-13T14:30:58.830

Reputation: 2 675

Question was closed 2019-11-13T16:30:43.470

3Related / 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. – Kevin Cruijssen – 2019-11-13T14:46:13.847

@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. – Uri Granta – 2019-11-13T15:40:13.890

Should I just close it as duplicate? – Uri Granta – 2019-11-13T15:41:03.787

1175 (75 bytes, 10.44% incorrect words). – Grimmy – 2019-11-13T17:28:11.457

No answers