From f08691d7fce18883b0fdb9c1664e84d4b2011dd0 Mon Sep 17 00:00:00 2001 From: hippietrail Date: Wed, 5 Feb 2025 11:14:08 +0800 Subject: [PATCH 1/4] feat: adds a brief helpful comment to each entry describing its function The name 'affixes' turns out to be a misnomer since about a quarter or a third of them don't add any prefix or suffix but change a property such as the part-of-speech, or singular vs plural. Another approach would be to switch from `json` to either [`JSON5`](https://json5.org/) or [`Hjson`](https://hjson.github.io/) --- harper-core/affixes.json | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/harper-core/affixes.json b/harper-core/affixes.json index 2c72dce7b..863a6de6d 100644 --- a/harper-core/affixes.json +++ b/harper-core/affixes.json @@ -1,6 +1,7 @@ { "affixes": { "K": { + "#": "'pro-' prefix", "suffix": false, "cross_product": true, "replacements": [ @@ -14,6 +15,7 @@ "gifts_metadata": {} }, "L": { + "#": "'-ment' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -27,6 +29,7 @@ "gifts_metadata": {} }, "E": { + "#": "'dis-' prefix", "suffix": false, "cross_product": true, "replacements": [ @@ -40,6 +43,7 @@ "gifts_metadata": {} }, "Y": { + "#": "'-ly' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -53,6 +57,7 @@ "gifts_metadata": {} }, "U": { + "#": "'un-' prefix", "suffix": false, "cross_product": true, "replacements": [ @@ -66,6 +71,7 @@ "gifts_metadata": {} }, "H": { + "#": "'-ieth' suffix", "suffix": true, "cross_product": false, "replacements": [ @@ -84,6 +90,7 @@ "gifts_metadata": {} }, "T": { + "#": "'-(i)est' suffix", "suffix": true, "cross_product": false, "replacements": [ @@ -112,6 +119,7 @@ "gifts_metadata": {} }, "R": { + "#": "'-(i)er' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -140,6 +148,7 @@ "gifts_metadata": {} }, "C": { + "#": "'de-' prefix", "suffix": false, "cross_product": true, "replacements": [ @@ -153,6 +162,7 @@ "gifts_metadata": {} }, "V": { + "#": "'-ive' suffix", "suffix": true, "cross_product": false, "replacements": [ @@ -171,6 +181,7 @@ "gifts_metadata": {} }, "N": { + "#": "nominalization suffixes", "suffix": true, "cross_product": true, "replacements": [ @@ -194,6 +205,7 @@ "gifts_metadata": {} }, "A": { + "#": "'re-' prefix", "suffix": false, "cross_product": true, "replacements": [ @@ -207,6 +219,7 @@ "gifts_metadata": {} }, "Z": { + "#": "'-(i)(e)rs' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -235,6 +248,7 @@ "gifts_metadata": {} }, "P": { + "#": "'-(i)ness' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -258,6 +272,7 @@ "gifts_metadata": {} }, "M": { + "#": "-'s possessive suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -277,6 +292,7 @@ } }, "F": { + "#": "'con-' prefix", "suffix": false, "cross_product": true, "replacements": [ @@ -290,6 +306,7 @@ "gifts_metadata": {} }, "B": { + "#": "'-able' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -313,6 +330,7 @@ "gifts_metadata": {} }, "S": { + "#": "'-(i)(e)s' plural suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -345,6 +363,7 @@ "gifts_metadata": {} }, "D": { + "#": "'-(e)d' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -377,6 +396,7 @@ "gifts_metadata": {} }, "G": { + "#": "'-ing' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -398,6 +418,7 @@ "gifts_metadata": {} }, "Q": { + "#": "'ally' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -411,6 +432,7 @@ "gifts_metadata": {} }, "O": { + "#": "'-ful' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -424,6 +446,7 @@ "gifts_metadata": {} }, "I": { + "#": "'in-' prefix", "suffix": false, "cross_product": true, "replacements": [ @@ -437,6 +460,7 @@ "gifts_metadata": {} }, "X": { + "#": "'-ions', '-ications', '-ens' suffixes", "suffix": true, "cross_product": true, "replacements": [ @@ -460,6 +484,7 @@ "gifts_metadata": {} }, "J": { + "#": "'-ings' suffix", "suffix": true, "cross_product": true, "replacements": [ @@ -478,6 +503,7 @@ "gifts_metadata": {} }, "1": { + "#": "singular noun property", "suffix": true, "cross_product": true, "replacements": [], @@ -489,6 +515,7 @@ } }, "2": { + "#": "proper noun property", "suffix": true, "cross_product": true, "replacements": [], @@ -500,6 +527,7 @@ } }, "3": { + "#": "linking verb property", "suffix": true, "cross_product": true, "replacements": [], @@ -511,6 +539,7 @@ } }, "4": { + "#": "verb property", "suffix": true, "cross_product": true, "replacements": [], @@ -520,6 +549,7 @@ } }, "5": { + "#": "adjective property", "suffix": true, "cross_product": true, "replacements": [], @@ -529,6 +559,7 @@ } }, "6": { + "#": "swear word property", "suffix": true, "cross_product": true, "replacements": [], @@ -540,6 +571,7 @@ } }, "7": { + "#": "conjunction property", "suffix": true, "cross_product": true, "replacements": [], @@ -549,6 +581,7 @@ } }, "8": { + "#": "pronoun property", "suffix": true, "cross_product": true, "replacements": [], @@ -560,6 +593,7 @@ } }, "9": { + "#": "plural noun property", "suffix": true, "cross_product": true, "replacements": [], @@ -571,6 +605,7 @@ } }, "~": { + "#": "common noun property", "suffix": true, "cross_product": true, "replacements": [], @@ -580,6 +615,7 @@ } }, "+": { + "#": "preposition property", "suffix": true, "cross_product": true, "replacements": [], @@ -589,6 +625,7 @@ } }, "-": { + "#": "article property", "suffix": true, "cross_product": true, "replacements": [], From 9af517c45ba13f3e1f6798a0e0635f07e35058e5 Mon Sep 17 00:00:00 2001 From: hippietrail Date: Wed, 5 Feb 2025 17:59:31 +0800 Subject: [PATCH 2/4] fix: /~ indicated a common word of any type, not a common noun --- harper-core/affixes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harper-core/affixes.json b/harper-core/affixes.json index 863a6de6d..c2869282f 100644 --- a/harper-core/affixes.json +++ b/harper-core/affixes.json @@ -605,7 +605,7 @@ } }, "~": { - "#": "common noun property", + "#": "common word property", "suffix": true, "cross_product": true, "replacements": [], From 73a5182d3ded9235c77e1d9adeebd6e654578441 Mon Sep 17 00:00:00 2001 From: hippietrail Date: Thu, 6 Feb 2025 00:47:49 +0800 Subject: [PATCH 3/4] feat: add printaffixes command to justfile --- justfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/justfile b/justfile index 041d0de38..7c7bab583 100644 --- a/justfile +++ b/justfile @@ -286,3 +286,9 @@ fuzz: exit $? fi done + +# Print affixes and their descriptions from affixes.json +printaffixes: + #! /bin/bash + node -e "Object.entries(require('./harper-core/affixes.json').affixes).forEach(([key, value]) => { if (value['#']) console.log(key + ': ' + value['#']); });" + \ No newline at end of file From 621a95875a20da8dc4ec1bbd208fbdbfdfe31eba Mon Sep 17 00:00:00 2001 From: hippietrail Date: Thu, 6 Feb 2025 13:01:16 +0800 Subject: [PATCH 4/4] chore: changed `just printaffixes` to use a "shebang recipe" Slight pain finding `{{justfile_directory()}}` needed for this transition. Took the opportunity to write the js in a clearer, hopefully self-documenting way --- justfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index 7c7bab583..524d11963 100644 --- a/justfile +++ b/justfile @@ -289,6 +289,10 @@ fuzz: # Print affixes and their descriptions from affixes.json printaffixes: - #! /bin/bash - node -e "Object.entries(require('./harper-core/affixes.json').affixes).forEach(([key, value]) => { if (value['#']) console.log(key + ': ' + value['#']); });" - \ No newline at end of file + #! /usr/bin/env node + Object.entries( + require('{{justfile_directory()}}/harper-core/affixes.json').affixes + ).forEach(([affix, fields]) => { + const description = fields['#'] || ''; + description && console.log(affix + ': ' + description); + });