Your task is to take as input an English noun and output its plural. To win the challenge you must trade off code length against accuracy.
Entries will be scored according to this comma-separated list of 95642 English nouns and their plurals. Your score is the length of your code in bytes, plus the number of nouns in this file that it does not correctly pluralise. If you manage to correctly pluralise every single line in the file then you may apply a 50% bonus. (I don't expect anyone to claim this, but you never know.) The lowest score wins.
Every line in the file consists of a word composed of letters [a-z]
, followed by ,
, followed by the plural, which is also composed of letters [a-z]
.
Please note that the data in the file is pretty terrible. It was scraped from Wiktionary using someone else's script. There are duplicates, there are things that are not real words, and there are entries that are clearly completely wrong. But none of this matters from the point of view of the challenge. The goal is to produce a program that will correctly reproduce the plurals as written in this file; their correspondence or otherwise to correct English plurals is irrelevant. Also please note that, like any dictionary, the provided file contains its fair share of offensive terms.
Input and output may be performed in any way you find convenient. (Function parameters, command-line input, etc.)
To evaluate your score you will probably need to write some testbed code that iterates over the provided file. Please include this in your answer. This code need not be in the same language as your pluralising program, and should not be golfed. (It should be readable, so we can verify that it works.)
A useful tip: while developing your code, you will probably find it helpful to modify your testbed code so that it prints out every line for which your function fails. That way you can easily see which additional cases you need to consider.
Illustrative examples
the Python code
def p(a):
return a+'s'
is 24 bytes. However, if we run it through the following evaluation function
def testPlural(func):
badLines = 0
with open("simpleNouns.csv") as file:
for line in file:
noun, plural = line.rstrip().split(',')
if plural != func(noun):
badLines += 1
return badLines
then we can see that it fails in 11246 cases, giving a score of 24 + 11246 = 11270.
However, if we update the function to
import re
def p(a):
a+='s'
return re.sub('ys$','ies',a)
then its length has increased to 58 bytes, but it now fails in only 7380 cases, giving a score of 58 + 7380 = 7438.
schwannomatosis,neurofibromatoses
?diphosphine,si
??!! \$\endgroup\$