Page 1 of 1
Numerological word generation calculator
Posted: Fri Oct 14, 2022 3:31 pm
by Nakrotam
Hello y'all!
So I'm wanting to make a language which has numerological connections between words. I'm thinking to do this I need a calculator which takes the list of numbers, and when given a sum can list all combinations that add up to the sum - with a limit on word length and number of times a letter can be repeated (obviously you don't want a bunch of results saying that a word consisting of 100 "a"s will add up to 100).
I've tried some search terms, but haven't even found anyone else who is wanting to deliberately code some numerology into their conlang (though I'm sure they're out there). Does anyone know of a tool I could use?
Thanks!
Re: Numerological word generation calculator
Posted: Sun Oct 23, 2022 1:27 pm
by Qwynegold
Hi! I think you need to post some examples, because I have no idea what you're really asking for.
Re: Numerological word generation calculator
Posted: Tue Oct 25, 2022 2:33 am
by holbuzvala
I think what Nakrotam is looking for is something like the following:
Imagine the following letters <a b c d e> have the values 1, 2, 3, 4, 5. Now, suppose you want to find all words with the value of '5'. You could have:
aaaaa = 1 + 1 + 1 + 1 + 1 = 5
aaab = 1 + 1 + 1 + 2 = 5
aaba = ...
abaa
baaa
abb
bab
bba
aac
aca
caa
bc
cb
ad
da
e
So it seems that Nakrotam wants a calculator that will spit out all these words, with an applicable 'reject' function (which I suppose would simply depend on the phonotactics of the language, like nixing outputs with too many vowels in a row or ones with disallowed clusters).
Re: Numerological word generation calculator
Posted: Tue Oct 25, 2022 9:01 am
by bradrn
Nakrotam wrote: ↑Fri Oct 14, 2022 3:31 pm
Hello y'all!
So I'm wanting to make a language which has numerological connections between words. I'm thinking to do this I need a calculator which takes the list of numbers, and when given a sum can list all combinations that add up to the sum - with a limit on word length and number of times a letter can be repeated (obviously you don't want a bunch of results saying that a word consisting of 100 "a"s will add up to 100).
I've tried some search terms, but haven't even found anyone else who is wanting to deliberately code some numerology into their conlang (though I'm sure they're out there). Does anyone know of a tool I could use?
Thanks!
I don’t know of any pre-existing programs which do this. However, here’s a quick-and-dirty
Haskell program which should suffice:
Code: Select all
module Main where
import Data.Foldable (traverse_)
import Data.List (group)
import System.IO (hSetBuffering, stdout, BufferMode(..))
import Text.Read (readMaybe)
import Data.IntMap.Strict ((!))
import qualified Data.IntMap.Strict as IM
-- see https://en.wikipedia.org/wiki/Composition_(combinatorics)#Number_of_compositions
compositions :: Int -> [[Int]]
compositions = go 1 . subtract 1
where
go :: Int -> Int -> [[Int]]
go k 0 = []
go k 1 = [[k,1],[k+1]]
go k n = ((k:) <$> go 1 (n-1)) ++ go (k+1) (n-1)
maxReps :: Eq a => [a] -> Int
maxReps = maximum . fmap length . group
getMapping :: IO (IM.IntMap String)
getMapping = do
putStrLn "(NB. Enter an empty line when you are done creating mappings)"
go IM.empty 1
where
go m n = do
putStr $ "Enter the letter corresponding to number " ++ show n ++ ": "
l <- getLine
let m' = IM.insert n l m
if null l
then pure m'
else go m' (n+1)
main :: IO ()
main = do
hSetBuffering stdout NoBuffering
m <- getMapping
putStr "What do you want your words to sum to? "
totalsum <- readLn :: IO Int
putStr "At most how many repetitions of a single letter in a row will you tolerate? "
reps <- readLn :: IO Int
let ws = filter ((<=reps) . maxReps) $ filter (all (<= (IM.size m))) $ compositions totalsum
traverse_ (putStrLn . concatMap (m !)) ws
Save the program as, say,
numerology.hs, then run it in the command prompt with
runghc numerology.hs (or similar) and follow the prompts.
EDIT: Hmm, on further testing this appears to be buggy. When I get some time to fix this I’ll post a new version.