We can write functions such as:
Term -> [possible Dewey matches]
[possible Dewey matches] -> tagWithChosenDeweyPrefix
deweyPrefix -> deweyName
which look things up in a JSON record of any size like:
{
"100": "Philosophy & psychology",
"101": "Theory of philosophy",
"102": "Miscellany",
"103": "Dictionaries & encyclopedias",
"104": "[Unassigned]",
"105": "Serial publications",
"106": "Organizations & management",
"107": "Education, research, related topics of philosophy",
"108": "Groups of people",
"109": "History & collected biography",
"110": "Metaphysics",
"111": "Ontology",
"112": "No longer used—formerly Methodology",
"113": "Cosmology (Philosophy of nature)",
"114": "Space",
"115": "Time",
"116": "Change",
"117": "Structure",
"118": "Force and energy",
"119": "Number and quantity",
"120": "Epistemology, causation, and humankind",
"121": "Epistemology (Theory of knowledge)",
"122": "Causation",
"123": "Determinism and indeterminism",
"124": "Teleology",
"125": "No longer used—formerly Infinity",
"126": "The self",
"127": "The unconscious & the subconscious",
"128": "Humankind",
"129": "Origin & destiny of individual souls",
"130": "Parapsychology & occultism",
"131": "Parapsychological and occult methods for achieving well-being, happiness, success",
"132": "No longer used—formerly Mental derangements",
"133": "Specific topics in parapsychology & occultism",
"134": "No longer used—formerly Mesmerism & Clairvoyance",
"135": "Dreams & mysteries",
"136": "No longer used—formerly Mental characteristics",
"137": "Divinatory graphology",
"138": "Physiognomy",
"139": "Phrenology",
"140": "Specific philosophical schools and viewpoints",
"141": "Idealism & related systems & doctrines",
"142": "Critical philosophy",
"143": "Bergsonism & intuitionism",
"144": "Humanism & related systems & doctrines",
"145": "Sensationalism",
"146": "Naturalism & related systems & doctrines",
"147": "Pantheism & related systems & doctrines",
"148": "Dogmatism, eclecticism, liberalism, syncretism, & traditionalism",
"149": "Other philosophical systems & doctrines",
"150": "Psychology",
"151": "No longer used—formerly Intellect",
"152": "Sensory perception, movement, emotions, & physiological drives",
"153": "Conscious mental processes & intelligence",
"154": "Subconscious & altered states & processes",
"155": "Differential & developmental psychology",
"156": "Comparative psychology",
"157": "No longer used—formerly Emotions",
"158": "Applied psychology",
"159": "No longer used—formerly Will",
"160": "Philosophical logic",
"161": "Induction",
"162": "Deduction",
"165": "Fallacies & sources of error",
"166": "Syllogisms",
"167": "Hypotheses",
"168": "Argument & persuasion",
"169": "Analogy",
"170": "Ethics (Moral philosophy)",
"171": "Ethical systems",
"172": "Political ethics",
"173": "Ethics of family relationships",
"174": "Occupational ethics",
"175": "Ethics of recreation, leisure, public performances, communication",
"176": "Ethics of sex & reproduction",
"177": "Ethics of social relations",
"178": "Ethics of consumption",
"179": "Other ethical norms",
"180": "Ancient, medieval, eastern philosophy",
"181": "Eastern philosophy",
"182": "Pre-Socratic Greek philosophies",
"183": "Sophistic, Socratic, related Greek philosophies",
"184": "Platonic philosophy",
"185": "Aristotelian philosophy",
"186": "Skeptic & Neoplatonic philosophies",
"187": "Epicurean philosophy",
"188": "Stoic philosophy",
"189": "Medieval Western philosophy",
"190": "Modern Western & other noneastern philosophy",
"191": "Philosophy of the United States and Canada",
"192": "Philosophy of the British Isles",
"193": "Philosophy of Germany and Austria",
"194": "Philosophy of France",
"195": "Philosophy of Italy",
"196": "Philosophy of Spain and Portugal",
"197": "Philosophy of Russia",
"198": "Philosophy of Scandinavia & Finland",
"199": "Philosophy in other geographic areas",
"163–164": "Not assigned or no longer used"
}
and we can produce such records automatically, from a copy-paste of one or more sections of List of Dewey Decimal classes]
(https://en.wikipedia.org/wiki/List_of_Dewey_Decimal_classes) for example, by writing JS expressions this kind:
(() => {
'use strict';
// main :: IO ()
const main = () => {
const
dictPartialDewey = lines(deweySample)
.reduce(
(sofar, line) => {
const parts = words(line);
return Object.assign(
sofar, {
[parts[0]]: unwords(
parts.slice(1)
)
}
);
}, {} // Seed value. (Empty dictionary)
);
return JSON.stringify(
dictPartialDewey,
null, 2
);
};
const deweySample = `100 Philosophy
100 Philosophy & psychology
101 Theory of philosophy
102 Miscellany
103 Dictionaries & encyclopedias
104 [Unassigned]
105 Serial publications
106 Organizations & management
107 Education, research, related topics of philosophy
108 Groups of people
109 History & collected biography
110 Metaphysics
110 Metaphysics
111 Ontology
112 No longer used—formerly Methodology
113 Cosmology (Philosophy of nature)
114 Space
115 Time
116 Change
117 Structure
118 Force and energy
119 Number and quantity
120 Epistemology
120 Epistemology, causation, and humankind
121 Epistemology (Theory of knowledge)
122 Causation
123 Determinism and indeterminism
124 Teleology
125 No longer used—formerly Infinity
126 The self
127 The unconscious & the subconscious
128 Humankind
129 Origin & destiny of individual souls
130 Parapsychology & occultism
130 Parapsychology & occultism
131 Parapsychological and occult methods for achieving well-being, happiness, success
132 No longer used—formerly Mental derangements
133 Specific topics in parapsychology & occultism
134 No longer used—formerly Mesmerism & Clairvoyance
135 Dreams & mysteries
136 No longer used—formerly Mental characteristics
137 Divinatory graphology
138 Physiognomy
139 Phrenology
140 Philosophical schools of thought
140 Specific philosophical schools and viewpoints
141 Idealism & related systems & doctrines
142 Critical philosophy
143 Bergsonism & intuitionism
144 Humanism & related systems & doctrines
145 Sensationalism
146 Naturalism & related systems & doctrines
147 Pantheism & related systems & doctrines
148 Dogmatism, eclecticism, liberalism, syncretism, & traditionalism
149 Other philosophical systems & doctrines
150 Psychology
150 Psychology
151 No longer used—formerly Intellect
152 Sensory perception, movement, emotions, & physiological drives
153 Conscious mental processes & intelligence
154 Subconscious & altered states & processes
155 Differential & developmental psychology
156 Comparative psychology
157 No longer used—formerly Emotions
158 Applied psychology
159 No longer used—formerly Will
160 Philosophical logic
160 Philosophical logic
161 Induction
162 Deduction
163–164 Not assigned or no longer used
165 Fallacies & sources of error
166 Syllogisms
167 Hypotheses
168 Argument & persuasion
169 Analogy
170 Ethics
170 Ethics (Moral philosophy)
171 Ethical systems
172 Political ethics
173 Ethics of family relationships
174 Occupational ethics
175 Ethics of recreation, leisure, public performances, communication
176 Ethics of sex & reproduction
177 Ethics of social relations
178 Ethics of consumption
179 Other ethical norms
180 Ancient, medieval, & Eastern philosophy
180 Ancient, medieval, eastern philosophy
181 Eastern philosophy
182 Pre-Socratic Greek philosophies
183 Sophistic, Socratic, related Greek philosophies
184 Platonic philosophy
185 Aristotelian philosophy
186 Skeptic & Neoplatonic philosophies
187 Epicurean philosophy
188 Stoic philosophy
189 Medieval Western philosophy
190 Modern Western philosophy (19th-century, 20th-century)
190 Modern Western & other noneastern philosophy
191 Philosophy of the United States and Canada
192 Philosophy of the British Isles
193 Philosophy of Germany and Austria
194 Philosophy of France
195 Philosophy of Italy
196 Philosophy of Spain and Portugal
197 Philosophy of Russia
198 Philosophy of Scandinavia & Finland
199 Philosophy in other geographic areas`;
// --------------------- GENERIC ---------------------
// lines :: String -> [String]
const lines = s =>
// A list of strings derived from a single
// string delimited by newline and or CR.
0 < s.length ? (
s.split(/[\r\n]+/)
) : [];
// unwords :: [String] -> String
const unwords = xs =>
// A space-separated string derived
// from a list of words.
xs.join(' ');
// words :: String -> [String]
const words = s =>
// List of space-delimited sub-strings.
s.split(/\s+/);
return main();
})();