Compare commits

...

2 Commits

Author SHA1 Message Date
ThePendulum 29cbd77e35 1.29.5 2024-06-09 23:37:19 +02:00
ThePendulum 2310352ad6 Improved dictionary processing. 2024-06-09 23:37:17 +02:00
5 changed files with 15113 additions and 15108 deletions

View File

@ -1,11 +1,11 @@
'use strict';
const fs = require('fs').promises;
/*
const inflect = require('inflect');
const tensify = require('tensify');
const dictionary = require('./dictionary.json');
function getTenses(word) {
try {
const { past, past_participle: participle } = tensify(word);
@ -15,21 +15,26 @@ function getTenses(word) {
return {};
}
}
*/
const dictionary = require('./dictionary.json');
async function init() {
/*
const formsDictionary = Object.fromEntries(Object.entries(dictionary).flatMap(([word, definition]) => {
const plural = inflect.pluralize(word);
const { past, participle } = getTenses(word);
return [
[word, definition],
...(plural && !dictionary[plural] ? [[plural, `Plural of ${word}`]] : []),
...(past && !dictionary[past] ? [[past, `Past tense of ${word}`]] : []),
...(participle && !dictionary[participle] ? [[past, `Past participle of ${word}`]] : []),
...(plural && !dictionary[plural] ? [[plural, definition]] : []),
...(past && !dictionary[past] ? [[past, definition]] : []),
...(participle && !dictionary[participle] ? [[past, definition]] : []),
];
}));
*/
const validWords = Object.entries(formsDictionary).filter(([word]) => /^[a-zA-Z]+$/.test(word));
const validWords = Object.entries(dictionary).filter(([word]) => /^[a-zA-Z]+$/.test(word));
const sortedWords = validWords.reduce((acc, [rawWord, fullDefinition]) => {
const word = rawWord.toLowerCase();

File diff suppressed because one or more lines are too long

View File

@ -10,9 +10,9 @@ async function init() {
const normalizedWord = word.normalize('NFD').replace(/\p{Diacritic}/ug, '').toLowerCase().trim();
const definition = dictionary[normalizedWord];
const singular = normalizedWord.replace(/s$/, '');
const singularDefinition = dictionary[singular] ? `Plural of ${singular}: ${dictionary[singular]}` : null;
const singularDefinition = dictionary[singular];
return [normalizedWord, definition || singularDefinition];
return [normalizedWord, definition || singularDefinition || null];
}));
const string = JSON.stringify(definitions, null, 4);

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "schat2-clive",
"version": "1.29.4",
"version": "1.29.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "schat2-clive",
"version": "1.29.4",
"version": "1.29.5",
"license": "ISC",
"dependencies": {
"better-sqlite3": "^8.3.0",

View File

@ -1,6 +1,6 @@
{
"name": "schat2-clive",
"version": "1.29.4",
"version": "1.29.5",
"description": "Game host for SChat 2-powered chat sites",
"main": "src/app.js",
"scripts": {