Numerological word generation calculator

Conworlds and conlangs
Post Reply
Nakrotam
Posts: 1
Joined: Fri Oct 14, 2022 3:23 pm

Numerological word generation calculator

Post 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!
Qwynegold
Posts: 722
Joined: Sun Jul 29, 2018 3:03 pm
Location: Stockholm

Re: Numerological word generation calculator

Post by Qwynegold »

Hi! I think you need to post some examples, because I have no idea what you're really asking for.
holbuzvala
Posts: 34
Joined: Thu Aug 22, 2019 2:22 am

Re: Numerological word generation calculator

Post 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).
bradrn
Posts: 5700
Joined: Fri Oct 19, 2018 1:25 am

Re: Numerological word generation calculator

Post 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.
Conlangs: Scratchpad | Texts | antilanguage
Software: See http://bradrn.com/projects.html
Other: Ergativity for Novices

(Why does phpBB not let me add >5 links here?)
Post Reply