# Determining part of speech of most words [closed]

Write a program to output the part of speech of any word inputted to it. I doubt that anyone could get a perfect algorithm, so I will give the code a batch of words in order to ascertain what algorithm is the best.

Weighted Scoring:
+10pts for each word identified correctly: http://www.englishclub.com/grammar/parts-of-speech_1.htm (out of 100 randomly selected words)
-1pt for each byte

Rules:
no using external resources (unless they are counted in the size)

UPDATE: Due to the need for a standardized word list for testing purposes, I will be using the list provided in the response to this question. http://www-personal.umich.edu/~jlawler/wordlist It seems to be a fairly complete list, and will make this a challenge more than a guessing game.

## closed as unclear what you're asking by Peter Taylor, SztupY, Howard, manatwork, gnibblerMar 3 '14 at 9:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• "+style points (tie-breakers, mostly.)" How are these determined? "no golfscript or other languages designed for code golf." Why not? – Doorknob Feb 28 '14 at 2:36
• "(out of 10 randomly selected words)": Randomly selected from what set? – DavidC Feb 28 '14 at 2:52
• I believe this is near impossible: programmers.stackexchange.com/a/133789/115106 – Zero Fiber Feb 28 '14 at 3:32
• @StackTracer It may be better to use 1000 randomly selected words, granting one point each, rather than 10 words each worth 100. – primo Feb 28 '14 at 6:04
• This isn't a spec: it's an invitation to write a mind-reading program. – Peter Taylor Feb 28 '14 at 9:29

# Mathematica

Mathematica has a native database of words (called up by the simple command WordData ) that includes, among other properties, the parts of speech. Without this database, it would be impossible for me to answer the question.

The word list from here was downloaded. Once stored, it is called up as follows:

words = Import["wordlist.txt", "Table"];
Length[words]


69905

Forty words are randomly chosen from the list:

list = Flatten@RandomSample[words, 40]


{"mealtime", "deride", "cricketground", "torpedinidae", "rosefish", "akron", "sloppy", "deaden", "assaultive", "mick", "unperceptiveness", "skeg", "pad", "mane", "carvel-built", "night-stop", "monarchy", "corking", "backlog", "scaphopoda", "bagman", "phrthe", "wholesome", "proprietress", "hortus", "unreliable", "farthermost", "fearfulness", "malposed", "stoke", "affiche", "lunatic", "holcus", "devoutness", "macaque", "zenithal", "poetry", "precipitate", "agoraphobic", "snapper"}

The following asks Mathematica to return the parts of speech for the list of 40 words. The parts of 31 words are identified. 9 words are not recognized.

(s = Select[Flatten@{{#}, WordData[#, "PartsOfSpeech"]} & /@
list, ! MatchQ[#, {_, WordData[_, _]}] &]) // TableForm
Length[s]


• Seems like cheating, using an internal dictionary.. – TheDoctor Feb 28 '14 at 23:22
• I agree. But it is essentially impossible to determine the part of speech of a word by raw computing power. Some sort of database is required. – DavidC Feb 28 '14 at 23:48
• "no using external resources (unless they are counted in the size)" What's your score? -1,000,000? – qwr Mar 1 '14 at 0:44
• It was't an external resource. And the word list did not contain information about parts of speech. It was used because the OP did not provide words to use as test cases. – DavidC Mar 1 '14 at 1:38
• This is currently the best solution. I do admit that I was hoping for something less cheaty than a database lookup, but there is no rule against it. I could see a way to do it based on word structure, but that gets rather fuzzy due to the nature of english. – Stack Tracer Mar 1 '14 at 4:31