Compare commits
2 Commits
5cc3a428f3
...
29cbd77e35
Author | SHA1 | Date |
---|---|---|
|
29cbd77e35 | |
|
2310352ad6 |
|
@ -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();
|
||||
|
|
30194
assets/dictionary.json
30194
assets/dictionary.json
File diff suppressed because one or more lines are too long
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in New Issue