Browse Source

added Webster's 1828 definitions to verse words

master
nerdy-sam 1 year ago
parent
commit
e4f87bc622
No known key found for this signature in database GPG Key ID: 8A814BCF72590007
5 changed files with 63102 additions and 19 deletions
  1. +62981
    -0
      bible_helps/webster1828_wordlist.js
  2. +3
    -1
      bibles/english_kjv.js
  3. +32
    -5
      bot.js
  4. +84
    -12
      package-lock.json
  5. +2
    -1
      package.json

+ 62981
- 0
bible_helps/webster1828_wordlist.js
File diff suppressed because it is too large
View File


bibles/english_kjv.json → bibles/english_kjv.js View File

@@ -1,4 +1,4 @@
[
const KJV = [
{"chapter":1,"verse":1,"text":"In the beginning God created the heaven and the earth.","book":"Genesis"},
{"chapter":1,"verse":2,"text":"And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.","book":"Genesis"},
{"chapter":1,"verse":3,"text":"And God said, Let there be light: and there was light.","book":"Genesis"},
@@ -31102,3 +31102,5 @@
{"chapter":22,"verse":20,"text":"He which testifieth these things saith, Surely I come quickly. Amen. Even so, come, Lord Jesus.","book":"Revelation"},
{"chapter":22,"verse":21,"text":"The grace of our Lord Jesus Christ be with you all. Amen.","book":"Revelation"}
]

export default KJV

+ 32
- 5
bot.js View File

@@ -14,8 +14,14 @@ import {
} from 'matrix-bot-sdk'
import schedule from 'node-schedule'
import { promises as fs } from 'fs'
import jw from 'talisman/metrics/jaro-winkler.js'
import words from 'talisman/tokenizers/words/index.js'

import config from './config.js'

import WEB1828 from './bible_helps/webster1828_wordlist.js'
import KJV from './bibles/english_kjv.js'

'use strict'

const matrix = new MatrixClient(
@@ -31,8 +37,6 @@ console.log('Matrix client started!')

console.log('Sending a Proverb every hour on the sevens.')

const KJV = JSON.parse(await fs.readFile('./bibles/english_kjv.json'))

const Proverbs = KJV.filter(verse => (verse.book == 'Proverbs'))

const oneMinuteMs = 1000 * 60
@@ -73,9 +77,30 @@ schedule.scheduleJob({
const xrefUrl = `${xrefDomain}/TSK/Proverbs/${chapter}/${verse}`
const xrefLink = `<b><a href="${xrefUrl}">X-REFs</a></b>`

const vHTML = `${vrefLink} ${Proverbs[verseIndex].text} ${xrefLink}`
const verseWords = words(Proverbs[verseIndex].text).map(verseWord => {
let w1828Scored = []

// find closest match in Websters 1828 Dictionary for verse word
WEB1828.forEach(dictWord => {
const jwNum = jw(dictWord.toLowerCase(), verseWord.toLowerCase())
w1828Scored.push({vw: verseWord, dw: dictWord, jw: jwNum})
})

// return first result of scored and sorted dictionary words
return w1828Scored.sort((a, b) => b.jw - a.jw)[0]
})

let vHTML = `${vrefLink} ${Proverbs[verseIndex].text} ${xrefLink}`

console.log(vHTML)
// replace each word with a link to its definition
verseWords.forEach(word => {
const webDomain = 'http://webstersdictionary1828.com/Dictionary'
const vDefined = ` <a href="${webDomain}/${word.dw}">${word.vw}</a>`
const vwRegEx = new RegExp(` ${word.vw}`)

vHTML = vHTML.replace(vwRegEx, vDefined)
})

config.rooms.proverbs.forEach((room, index) => {
// add delay to throttle sending messages to many rooms
@@ -84,7 +109,9 @@ schedule.scheduleJob({
const delay = threeSec * ratio
const delayedDate = new Date(Date.now() + delay)

console.log(`${room.name} scheduled for ${delayedDate}`)
console.log(
`${vrefLink} scheduled for ${room.name} on ${delayedDate.toTimeString()}`
)

schedule.scheduleJob(
delayedDate,


+ 84
- 12
package-lock.json View File

@@ -1,5 +1,5 @@
{
"name": "bot",
"name": "eliezer",
"version": "0.0.1",
"lockfileVersion": 2,
"requires": true,
@@ -10,7 +10,7 @@
"dependencies": {
"matrix-bot-sdk": "^0.5.19",
"node-schedule": "^2.0.0",
"sunrise-sunset-js": "^2.2.1"
"talisman": "^1.1.4"
}
},
"node_modules/@types/body-parser": {
@@ -738,6 +738,11 @@
"he": "bin/he"
}
},
"node_modules/html-entities": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.4.0.tgz",
"integrity": "sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA=="
},
"node_modules/html-to-text": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-6.0.0.tgz",
@@ -915,6 +920,11 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/long": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"node_modules/long-timeout": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz",
@@ -1050,6 +1060,14 @@
"node": ">=10"
}
},
"node_modules/mnemonist": {
"version": "0.38.3",
"resolved": "https://registry.npmjs.org/mnemonist/-/mnemonist-0.38.3.tgz",
"integrity": "sha512-2K9QYubXx/NAjv4VLq1d1Ly8pWNC5L3BrixtdkyTegXWJIqY+zLNDhhX/A+ZwWt70tB1S8H4BE8FLYEFyNoOBw==",
"dependencies": {
"obliterator": "^1.6.1"
}
},
"node_modules/morgan": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz",
@@ -1126,6 +1144,11 @@
"node": ">= 0.4"
}
},
"node_modules/obliterator": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/obliterator/-/obliterator-1.6.1.tgz",
"integrity": "sha512-9WXswnqINnnhOG/5SLimUlzuU1hFJUc8zkwyD59Sd+dPOMf05PmnYG/d6Q7HZ+KmgkZJa1PxRso6QdM3sTNHig=="
},
"node_modules/on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
@@ -1145,6 +1168,11 @@
"node": ">= 0.8"
}
},
"node_modules/pandemonium": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/pandemonium/-/pandemonium-2.0.0.tgz",
"integrity": "sha512-ACX7eLSSL7XKZEPxHw1HsZyjLDajIPuN5IFppmwwFs/xKE1FZF87cVk5bSg0ZI9lpA4DBTju/6KGDdrcwGG2rg=="
},
"node_modules/parse-srcset": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz",
@@ -1483,11 +1511,6 @@
"graceful-fs": "^4.1.3"
}
},
"node_modules/sunrise-sunset-js": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/sunrise-sunset-js/-/sunrise-sunset-js-2.2.1.tgz",
"integrity": "sha512-ErsvmxoTCZRacVPtlchkrTAR8qxypBy0BDrrv9LMugLuF0AykcS5pQsP1EhQJHgumxrTTSI8N8KJkQMVJ6dEPw=="
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -1499,6 +1522,19 @@
"node": ">=8"
}
},
"node_modules/talisman": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/talisman/-/talisman-1.1.4.tgz",
"integrity": "sha512-XZ/vf5B2aW5A0c0CE6F6w/UgdBdD/0ClBgh/phpYSjV1CnQIFni3bKZ1z9ZXWHkGZRSpnbiWWMPx05DoxXBoFw==",
"dependencies": {
"html-entities": "^1.4.0",
"lodash": "^4.17.20",
"long": "^4.0.0",
"mnemonist": "^0.38.1",
"obliterator": "^1.6.1",
"pandemonium": "^2.0.0"
}
},
"node_modules/toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
@@ -2176,6 +2212,11 @@
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
},
"html-entities": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.4.0.tgz",
"integrity": "sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA=="
},
"html-to-text": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-6.0.0.tgz",
@@ -2321,6 +2362,11 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"long": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"long-timeout": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz",
@@ -2420,6 +2466,14 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
},
"mnemonist": {
"version": "0.38.3",
"resolved": "https://registry.npmjs.org/mnemonist/-/mnemonist-0.38.3.tgz",
"integrity": "sha512-2K9QYubXx/NAjv4VLq1d1Ly8pWNC5L3BrixtdkyTegXWJIqY+zLNDhhX/A+ZwWt70tB1S8H4BE8FLYEFyNoOBw==",
"requires": {
"obliterator": "^1.6.1"
}
},
"morgan": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz",
@@ -2474,6 +2528,11 @@
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
},
"obliterator": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/obliterator/-/obliterator-1.6.1.tgz",
"integrity": "sha512-9WXswnqINnnhOG/5SLimUlzuU1hFJUc8zkwyD59Sd+dPOMf05PmnYG/d6Q7HZ+KmgkZJa1PxRso6QdM3sTNHig=="
},
"on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
@@ -2487,6 +2546,11 @@
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz",
"integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA=="
},
"pandemonium": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/pandemonium/-/pandemonium-2.0.0.tgz",
"integrity": "sha512-ACX7eLSSL7XKZEPxHw1HsZyjLDajIPuN5IFppmwwFs/xKE1FZF87cVk5bSg0ZI9lpA4DBTju/6KGDdrcwGG2rg=="
},
"parse-srcset": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz",
@@ -2747,11 +2811,6 @@
"graceful-fs": "^4.1.3"
}
},
"sunrise-sunset-js": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/sunrise-sunset-js/-/sunrise-sunset-js-2.2.1.tgz",
"integrity": "sha512-ErsvmxoTCZRacVPtlchkrTAR8qxypBy0BDrrv9LMugLuF0AykcS5pQsP1EhQJHgumxrTTSI8N8KJkQMVJ6dEPw=="
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -2760,6 +2819,19 @@
"has-flag": "^4.0.0"
}
},
"talisman": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/talisman/-/talisman-1.1.4.tgz",
"integrity": "sha512-XZ/vf5B2aW5A0c0CE6F6w/UgdBdD/0ClBgh/phpYSjV1CnQIFni3bKZ1z9ZXWHkGZRSpnbiWWMPx05DoxXBoFw==",
"requires": {
"html-entities": "^1.4.0",
"lodash": "^4.17.20",
"long": "^4.0.0",
"mnemonist": "^0.38.1",
"obliterator": "^1.6.1",
"pandemonium": "^2.0.0"
}
},
"toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",


+ 2
- 1
package.json View File

@@ -11,6 +11,7 @@
"license": "BlueOak-1.0.0",
"dependencies": {
"matrix-bot-sdk": "^0.5.19",
"node-schedule": "^2.0.0"
"node-schedule": "^2.0.0",
"talisman": "^1.1.4"
}
}

Loading…
Cancel
Save