9
$\begingroup$

I was going through the Wolfram Language book in Mathematica and in one chapter had the following exercise to pick out palindromes:

In[2]:= Select[WordList["KnownWords", Language -> "English"], 
 StringReverse[#] == # &]

Out[2]= {"0", "1", "101", "11", "2", "22", "3", "33", "4", "44", "5", \
"55", "6", "66", "7", "77", "8", "88", "9", "99", "a", "A", "aa", \
"AA", "AAA", "aba", "ADA", "aha", "ala", "alula", "ana", "anna", "b", \
"B", "BB", "bib", "bob", "boob", "c", "C", "CBC", "cc", "ccc", "CDC", \
"CFC", "civic", "CTC", "d", "D", "dad", "DD", "deed", "DMD", "DoD", \
"dud", "DVD", "e", "E", "EE", "ENE", "ere", "ESE", "eve", "ewe", \
"eye", "f", "F", "g", "G", "gag", "gig", "h", "H", "hah", "hallah", \
"heh", "huh", "i", "I", "ii", "II", "iii", "III", "ISI", "j", "J", \
"k", "K", "kayak", "KKK", "kook", "l", "L", "LDL", "level", "m", "M", \
"ma'am", "madam", "mem", "minim", "mm", "mom", "mum", "mym", "n", \
"N", "naan", "nan", "non", "noon", "nun", "o", "O", "oho", "p", "P", \
"pap", "PCP", "peep", "pep", "pip", "poop", "pop", "PPP", "pup", "q", \
"Q", "r", "R", "radar", "refer", "rotor", "s", "S", "SAS", "siris", \
"sis", "SLS", "SOS", "SS", "SSS", "succus", "t", "T", "tat", "TAT", \
"TDT", "tenet", "tit", "TNT", "toot", "tot", "TT", "tut", "tut-tut", \
"u", "U", "v", "V", "w", "W", "waw", "WNW", "wow", "WSW", "WWW", "x", \
"X", "xix", "XIX", "xx", "XX", "xxx", "XXX", "y", "Y", "z", "Z"}

The WordList function takes "KnownWords" as a parameter, which, according to the docs, specifies known dictionary words. I see quite a few strings that I can't believe are considered dictionary words, e.g. individual letters of the alphabet, numbers, some acronyms, etc. Why are these included in this WordList subset? Keep in mind that the above is just the list of palindromes, meaning there are likely many more of these.

$\endgroup$
  • $\begingroup$ Individual letters and all acronyms that I looked up except for TDT exist in Oxford Dictionary. Maybe DictionaryLookup, as it does not include that acronym, or numbers, or individual letters. $\endgroup$ – C. E. Apr 15 '16 at 10:41
13
$\begingroup$

Apparently the list "KnownWords" is very inclusive; it has cardinal numbers, alphabet letters, and many obscure words and abbreviations.

You may be more interested to use "CommonWords",

Select[WordList["CommonWords", Language -> "English"], 
 StringReverse[#] == # &]
(* {"a", "aha", "bib", "bob", "boob", "civic", "dad", "deed", 
"dud", "ere", "eve", "ewe", "eye", "gag", "gig", "huh", "kayak", 
"kook", "level", "ma'am", "madam", "minim", "mom", "mum", "nan", 
"non", "noon", "nun", "oho", "pap", "peep", "pep", "pip", "poop", 
"pop", "pup", "radar", "refer", "rotor", "sis", "tat", "tenet", 
"toot", "tot", "tut", "wow"} *)

Here's a WordCloud of the common palindrome's, weighted by the "ConceptWeight" of the words,

{#, Total[WordData[#, "ConceptWeight"][[All, -1]]]} & /@ 
  Select[WordList["CommonWords", Language -> "English"], 
   StringReverse[#] == # &] // WordCloud

enter image description here

You could use WordFrequency for the weighting, but it's much slower and less interesting (spoiler: "a" is by far the most used palindrome in the list).

But you can satisfy your own curiosity about why they are included in the list, and whether they are "non-words"

First[WordData[#, "Definitions"]] & /@ 
  Select[WordList["KnownWords", Language -> "English"], 
   StringReverse[#] == # &] // ExportString[#, "Table"] &


{"0", "Noun"} -> "a mathematical element that when added to another number yields the same number"
{"1", "Noun"} -> "the smallest whole number or a numeral representing this number"
{"101", "Adjective"} -> "being one more than one hundred"
{"11", "Noun"} -> "the cardinal number that is the sum of ten and one"
{"2", "Noun"} -> "the cardinal number that is the sum of one and one or a numeral representing this number"
{"22", "Noun"} -> "the cardinal number that is the sum of twenty-one and one"
{"3", "Noun"} -> "the cardinal number that is the sum of one and one and one"
{"33", "Adjective"} -> "being three more than thirty"
{"4", "Noun"} -> "the cardinal number that is the sum of three and one"
{"44", "Adjective"} -> "being four more than forty"
{"5", "Noun"} -> "the cardinal number that is the sum of four and one"
{"55", "Adjective"} -> "being five more than fifty"
{"6", "Noun"} -> "the cardinal number that is the sum of five and one"
{"66", "Adjective"} -> "being six more than sixty"
{"7", "Noun"} -> "the cardinal number that is the sum of six and one"
{"77", "Adjective"} -> "being seven more than seventy"
{"8", "Noun"} -> "the cardinal number that is the sum of seven and one"
{"88", "Adjective"} -> "being eight more than eighty"
{"9", "Noun"} -> "the cardinal number that is the sum of eight and one"
{"99", "Adjective"} -> "being nine more than ninety"
{"a", "Noun"} -> "the 1st letter of the Roman alphabet"
{"A", "Noun", "BloodType"} -> "the blood group whose red cells carry the A antigen"
{"aa", "Noun"} -> "a dry form of lava resembling clinkers"
{"AA", "Noun", "Associate"} -> "an associate degree in arts"
{"AAA", "Noun"} -> "an aneurysm of the abdominal aorta associated with old age and hypertension"
{"aba", "Noun", "Fabric"} -> "a fabric woven from goat hair and camel hair"
{"ADA", "Noun"} -> "an enzyme found in mammals that can catalyze the deamination of adenosine into inosine and ammonia"
{"aha", "Interjection"} -> "interjection"
{"ala", "Noun", "Wing"} -> "a wing of an insect"
{"alula", "Noun", "Feather"} -> "tuft of small stiff feathers on the first digit of a bird's wing"
{"ana", "Noun"} -> "a collection of anecdotes about a person or place"
{"anna", "Noun"} -> "a former copper coin of Pakistan and India"
{"b", "Noun", "LetterOfTheAlphabet"} -> "the 2nd letter of the Roman alphabet"
{"B", "Noun", "Eubacterium"} -> "aerobic rod-shaped spore-producing bacterium; often occurring in chainlike formations; found primarily in soil"
{"BB", "Noun"} -> "a small pellet fired from an air rifle or BB gun"
{"bib", "Noun", "TableNapkin"} -> "a napkin tied under the chin of a child while eating"
{"bob", "Noun", "Inclination"} -> "a short abrupt inclination (as of the head)"
{"boob", "Noun", "Mamma"} -> "either of two soft fleshy milk-secreting glandular organs on the chest of a woman"
{"c", "Noun", "LetterOfTheAlphabet"} -> "the 3rd letter of the Roman alphabet"
{"C", "Noun", "Cocaine"} -> "street names for cocaine"
{"CBC", "Noun"} -> "counting the number of white and red blood cells and the number of platelets in 1 cubic millimeter of blood"
{"cc", "Noun"} -> "a metric unit of volume equal to one thousandth of a liter"
{"ccc", "Adjective"} -> "being one hundred more than two hundred"
{"CDC", "Noun"} -> "a federal agency in the Department of Health and Human Services; located in Atlanta; investigates and diagnoses and tries to control or prevent diseases (especially new and unusual diseases)"
{"CFC", "Noun"} -> "a fluorocarbon with chlorine; formerly used as a refrigerant and as a propellant in aerosol cans"
{"civic", "Adjective", "Civil"} -> "of or relating to or befitting citizens as individuals"
{"CTC", "Noun"} -> "an agency that helps the Director of Central Intelligence coordinate counterterrorist efforts in order to preempt and disrupt and defeat terrorist activities at the earliest possible stage"
{"d", "Noun"} -> "the 4th letter of the Roman alphabet"
{"D", "Noun", "LetterOfTheAlphabet"} -> "the 4th letter of the Roman alphabet"
{"dad", "Noun"} -> "an informal term for a father; probably derived from baby talk"
{"DD", "Noun"} -> "a doctor's degree in religion"
{"deed", "Noun", "Event"} -> "something that people do or cause to happen"
{"DMD", "Noun"} -> "a doctor's degree in dental medicine"
{"DoD", "Noun"} -> "the federal department responsible for safeguarding national security of the United States; created in 1947"
{"dud", "Noun", "Bust"} -> "an event that fails badly or is totally ineffectual"
{"DVD", "Noun"} -> "a digital recording (as of a movie) on an optical disk that can be played on a computer or a television set"
{"e", "Noun", "LetterOfTheAlphabet"} -> "the 5th letter of the Roman alphabet"
{"E", "Noun", "LetterOfTheAlphabet"} -> "the 5th letter of the Roman alphabet"
{"EE", "Noun"} -> "the branch of engineering science that studies the uses of electricity and the equipment for power generation and distribution and the control of machines and communication"
{"ENE", "Noun"} -> "the compass point midway between northeast and east"
{"ere", "Preposition"} -> "preposition"
{"ESE", "Noun"} -> "the compass point midway between east and southeast"
{"eve", "Noun", "SolarDay"} -> "the day before"
{"ewe", "Noun"} -> "female sheep"
{"eye", "Noun", "Hole"} -> "a small hole or loop (as in a needle)"
{"f", "Noun"} -> "the 6th letter of the Roman alphabet"
{"F", "Noun", "LetterOfTheAlphabet"} -> "the 6th letter of the Roman alphabet"
{"g", "Noun", "LetterOfTheAlphabet"} -> "the 7th letter of the Roman alphabet"
{"G", "Noun", "LetterOfTheAlphabet"} -> "the 7th letter of the Roman alphabet"
{"gag", "Noun", "Restraint"} -> "restraint put into a person's mouth to prevent speaking or shouting"
{"gig", "Noun", "Engagement"} -> "a booking for musicians"
{"h", "Noun", "LetterOfTheAlphabet"} -> "the 8th letter of the Roman alphabet"
{"H", "Noun", "PhysicalProperty"} -> "(thermodynamics) a thermodynamic quantity equal to the internal energy of a system plus the product of its volume and pressure"
{"hah", "Interjection"} -> "interjection"
{"hallah", "Noun"} -> "(Judaism) a loaf of white bread containing eggs and leavened with yeast; often formed into braided loaves and glazed with eggs before baking"
{"heh", "Interjection"} -> "interjection"
{"huh", "Interjection"} -> "interjection"
{"i", "Noun"} -> "the 9th letter of the Roman alphabet"
{"I", "Noun", "LetterOfTheAlphabet"} -> "the 9th letter of the Roman alphabet"
{"ii", "Adjective"} -> "being one more than one"
{"II", "Noun"} -> "the cardinal number that is the sum of one and one or a numeral representing this number"
{"iii", "Adjective"} -> "being one more than two"
{"III", "Noun"} -> "the cardinal number that is the sum of one and one and one"
{"ISI", "Noun"} -> "the Pakistan intelligence agency; a powerful and almost autonomous political and military force; has procured nuclear technology and delivery capabilities; has had strong ties with the Taliban and other militant Islamic groups"
{"j", "Noun"} -> "the 10th letter of the Roman alphabet"
{"J", "Noun", "LetterOfTheAlphabet"} -> "the 10th letter of the Roman alphabet"
{"k", "Noun"} -> "the 11th letter of the Roman alphabet"
{"K", "Noun", "Ketamine"} -> "street names for ketamine"
{"kayak", "Noun"} -> "a small canoe consisting of a light frame made watertight with animal skins; used by Eskimos"
{"KKK", "Noun"} -> "a secret society of white Southerners in the United States; was formed in the 19th century to resist the emancipation of slaves; used terrorist tactics to suppress Black people"
{"kook", "Noun"} -> "someone regarded as eccentric or crazy and standing out from a group"
{"l", "Noun", "LetterOfTheAlphabet"} -> "the 12th letter of the Roman alphabet"
{"L", "Noun", "LetterOfTheAlphabet"} -> "the 12th letter of the Roman alphabet"
{"LDL", "Noun"} -> "a lipoprotein that transports cholesterol in the blood; composed of moderate amount of protein and a large amount of cholesterol; high levels are thought to be associated with increased risk of coronary heart disease and atherosclerosis"
{"level", "Noun", "Construction"} -> "a structure consisting of a room or set of rooms at a single position along a vertical scale"
{"m", "Noun", "LetterOfTheAlphabet"} -> "the 13th letter of the Roman alphabet"
{"M", "Noun", "Concentration"} -> "concentration measured by the number of moles of solute per liter of solution"
{"ma'am", "Noun"} -> "a woman of refinement"
{"madam", "Noun", "Woman"} -> "a woman of refinement"
{"mem", "Noun"} -> "the 13th letter of the Hebrew alphabet"
{"minim", "Noun", "Note"} -> "a musical note having the time value of half a whole note"
{"mm", "Noun"} -> "a metric unit of length equal to one thousandth of a meter"
{"mom", "Noun"} -> "informal terms for a mother"
{"mum", "Noun", "Secretiveness"} -> "secrecy"
{"mym", "Noun"} -> "a metric unit of length equal to 10,000 meters"
{"n", "Noun"} -> "the 14th letter of the Roman alphabet"
{"N", "Noun", "LetterOfTheAlphabet"} -> "the 14th letter of the Roman alphabet"
{"naan", "Noun"} -> "leavened bread baked in a clay oven in India; usually shaped like a teardrop"
{"nan", "Noun", "Bread"} -> "leavened bread baked in a clay oven in India; usually shaped like a teardrop"
{"non", "Adverb"} -> "negation of a word or group of words"
{"noon", "Noun"} -> "the middle of the day"
{"nun", "Noun", "LetterOfTheAlphabet"} -> "the 14th letter of the Hebrew alphabet"
{"o", "Noun"} -> "the 15th letter of the Roman alphabet"
{"O", "Noun", "BloodType"} -> "the blood group whose red cells carry neither the A nor B antigens"
{"oho", "Interjection"} -> "interjection"
{"p", "Noun"} -> "the 16th letter of the Roman alphabet"
{"P", "Noun", "LetterOfTheAlphabet"} -> "the 16th letter of the Roman alphabet"
{"pap", "Noun", "SexOrgan"} -> "the small projection of a mammary gland"
{"PCP", "Noun", "PsychedelicDrug"} -> "a drug used as an anesthetic by veterinarians; illicitly taken (originally in the form of powder or `dust') for its effects as a hallucinogen"
{"peep", "Noun", "Looking"} -> "a secret look"
{"pep", "Noun"} -> "liveliness and energy"
{"pip", "Noun", "RadarEcho"} -> "a radar echo displayed so as to show the position of a reflecting surface"
{"poop", "Noun", "Back"} -> "the rear part of a ship"
{"pop", "Noun", "PopularMusicGenre"} -> "music of general appeal to teenagers; a bland watered-down version of rock'n'roll with more rhythm and harmony and an emphasis on romantic love"
{"PPP", "Noun"} -> "surgical resection of unnecessary palatal and oropharyngeal tissue to open the airway; intended to cure extreme cases of snoring (with or without sleep apnea)"
{"pup", "Noun", "YoungMammal"} -> "young of any of various canines such as a dog or wolf"
{"q", "Noun"} -> "the 17th letter of the Roman alphabet"
{"Q", "Noun"} -> "the 17th letter of the Roman alphabet"
{"r", "Noun", "Length"} -> "the length of a line segment between the center and circumference of a circle or sphere"
{"R", "Noun", "LetterOfTheAlphabet"} -> "the 18th letter of the Roman alphabet"
{"radar", "Noun"} -> "measuring instrument in which the echo of a pulse of microwave radiation is used to detect and locate distant objects"
{"refer", "Verb", "Classify"} -> "think of, regard, or classify under a subsuming principle or with a general group or in relation to another"
{"rotor", "Noun", "RotatingMechanism"} -> "rotating mechanism consisting of an assembly of rotating airfoils"
{"s", "Noun", "LetterOfTheAlphabet"} -> "the 19th letter of the Roman alphabet"
{"S", "Noun", "PhysicalProperty"} -> "(thermodynamics) a thermodynamic quantity representing the amount of energy in a system that is no longer available for doing mechanical work"
{"SAS", "Noun"} -> "a specialist regiment of the British army that is trained in commando techniques of warfare and used in clandestine operations (especially against terrorist groups)"
{"siris", "Noun"} -> "large spreading Old World tree having large leaves and globose clusters of greenish-yellow flowers and long seed pods that clatter in the wind"
{"sis", "Noun"} -> "a female person who has the same parents as another person"
{"SLS", "Noun"} -> "a caustic detergent useful for removing grease; although commonly included in personal care items (shampoos and toothpastes etc.) it can irritate skin and should not be swallowed"
{"SOS", "Noun"} -> "an internationally recognized distress signal in radio code"
{"SS", "Noun", "PoliceForce"} -> "special police force in Nazi Germany founded as a personal bodyguard for Adolf Hitler in 1925; the SS administered the concentration camps"
{"SSS", "Noun"} -> "an independent federal agency that administers compulsory military service"
{"succus", "Noun"} -> "any of several liquids of the body"
{"t", "Noun", "LetterOfTheAlphabet"} -> "the 20th letter of the Roman alphabet"
{"T", "Noun", "Thyroxin"} -> "hormone produced by the thyroid glands to regulate metabolism by controlling the rate of oxidation in cells"
{"tat", "Noun"} -> "tastelessness by virtue of being cheap and vulgar"
{"TAT", "Noun"} -> "a projective technique using black-and-white pictures; subjects tell a story about each picture"
{"TDT", "Noun"} -> "(astronomy) a measure of time defined by Earth's orbital motion; terrestrial time is mean solar time corrected for the irregularities of the Earth's motions"
{"tenet", "Noun"} -> "a religious doctrine that is proclaimed as true without proof"
{"tit", "Noun", "OscineBird"} -> "small insectivorous birds"
{"TNT", "Noun"} -> "explosive consisting of a yellow crystalline compound that is a flammable toxic derivative of toluene"
{"toot", "Noun", "Revelry"} -> "revelry in drinking; a merry drinking party"
{"tot", "Noun", "SmallFry"} -> "a young child"
{"TT", "Noun", "Micronesia"} -> "a country scattered over Micronesia with a constitutional government in free association with the United States; achieved independence in 1986"
{"tut", "Verb"} -> "utter `tsk,' `tut,' or `tut-tut,' as in disapproval"
{"tut-tut", "Verb"} -> "utter `tsk,' `tut,' or `tut-tut,' as in disapproval"
{"u", "Noun"} -> "the 21st letter of the Roman alphabet"
{"U", "Noun", "LetterOfTheAlphabet"} -> "the 21st letter of the Roman alphabet"
{"v", "Noun"} -> "the 22nd letter of the Roman alphabet"
{"V", "Noun", "LetterOfTheAlphabet"} -> "the 22nd letter of the Roman alphabet"
{"w", "Noun"} -> "the 23rd letter of the Roman alphabet"
{"W", "Noun", "LetterOfTheAlphabet"} -> "the 23rd letter of the Roman alphabet"
{"waw", "Noun"} -> "the 6th letter of the Hebrew alphabet"
{"WNW", "Noun"} -> "the compass point midway between west and northwest"
{"wow", "Noun"} -> "a joke that seems extremely funny"
{"WSW", "Noun"} -> "the compass point midway between west and southwest"
{"WWW", "Noun"} -> "computer network consisting of a collection of internet sites that offer text and graphics and sound and animation resources through the hypertext transfer protocol"
{"x", "Noun"} -> "the 24th letter of the Roman alphabet"
{"X", "Noun", "Methylenedioxymethamphetamine"} -> "street names for methylenedioxymethamphetamine"
{"xix", "Adjective"} -> "being one more than eighteen"
{"XIX", "Noun"} -> "the cardinal number that is the sum of eighteen and one"
{"xx", "Adjective"} -> "denoting a quantity consisting of 20 items or units"
{"XX", "Noun", "SexChromosome"} -> "(genetics) normal complement of sex chromosomes in a female"
{"xxx", "Adjective"} -> "being ten more than twenty"
{"XXX", "Noun", "SexChromosome"} -> "(genetics) abnormal complement of three X chromosomes in a female"
{"y", "Noun"} -> "the 25th letter of the Roman alphabet"
{"Y", "Noun", "LetterOfTheAlphabet"} -> "the 25th letter of the Roman alphabet"
{"z", "Noun"} -> "the 26th letter of the Roman alphabet"
{"Z", "Noun", "LetterOfTheAlphabet"} -> "the 26th letter of the Roman alphabet"

and here's the "KnownWords" palindrome word cloud,

enter image description here

$\endgroup$
  • 2
    $\begingroup$ {"wow", "Noun"} -> "a joke that seems extremely funny" Next time someone asks me to tell a joke, I'll just say 'wow'. $\endgroup$ – QuantumDot Apr 15 '16 at 7:56
  • $\begingroup$ When I first saw this post, I thought "Okay, now there will finally be a relevant google search result for 'poop + Mathematica' " but then I did the search and there are some hits, even from this site. Also, I only included the first definition for each word for brevity, but I'm disappointed that "XXX" gives a genetics definition.... $\endgroup$ – Jason B. Apr 15 '16 at 7:59
  • $\begingroup$ @JasonB do you know the source of Mathematica's WordData? Is it a superset of the Oxford and Merriam-Webster dictionaries or is it Wolfram's own curated set of words? $\endgroup$ – Adrian Apr 15 '16 at 15:46
  • $\begingroup$ @Adrian I'm not sure, but one way to find out would be to take several definitions for different words and do a google search using quotation marks to make sure you only found exact matches. $\endgroup$ – Jason B. Apr 15 '16 at 18:51
  • $\begingroup$ @JasonB, I considered automating a check against both of the dictionaries I mentioned, but I didn't find any free, ready-to-use APIs available. It'd be possible to scrape some of their browser targeted responses, though... Checking a few of the Mathematica returned words against both, I think I did find some that didn't turn up in either - at least in the unabridged versions. In fact, when looking up one, they tried to upsell me to subscribe in order to give me the definition from the unabridged data. $\endgroup$ – Adrian Apr 15 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.