Skip to content

Commit

Permalink
Merge pull request #19 from stscoundrel/feature/staveless-futhark
Browse files Browse the repository at this point in the history
Add Staveless Futhark
  • Loading branch information
stscoundrel authored Jul 27, 2022
2 parents 6eba0e2 + 8eb9a76 commit edca32b
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
23 changes: 23 additions & 0 deletions riimut_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/stscoundrel/riimut-go/elderfuthark"
"github.com/stscoundrel/riimut-go/futhorc"
"github.com/stscoundrel/riimut-go/medievalfuthork"
"github.com/stscoundrel/riimut-go/stavelessfuthark"
"github.com/stscoundrel/riimut-go/youngerfuthark"
)

Expand Down Expand Up @@ -96,3 +97,25 @@ func TestFuthorcTransformsRunesToletters(t *testing.T) {
t.Error("Did not transform runes to letters. Received", result, "expected ", expected)
}
}

func TestStavelessFutharkTransformsLettersToRunes(t *testing.T) {
// From Old Norse text in Hög runestone.
const content = "kuþniutr þru sun lit rita stin þina ak bru kirþi aftiʀ bruþr sina asbiurn ak at kuþlaf"
const expected = "ᛍ╮ו⸜ᛁ╮⸍◟:ו◟╮:╵╮⸜:⸌ᛁ⸍:◟ᛁ⸍⸝:╵⸍ᛁ⸜:וᛁ⸜⸝:⸝ᛍ:ˏ◟╮:ᛍᛁ◟וᛁ:⸝ᛙ⸍ᛁʀ:ˏ◟╮ו◟:╵ᛁ⸜⸝:⸝╵ˏᛁ╮◟⸜:⸝ᛍ:⸝⸍:ᛍ╮ו⸌⸝ᛙ"
result := stavelessfuthark.LettersToRunes(content)

if result != expected {
t.Error("Did not transform letters to runes. Received", result, "expected ", expected)
}
}

func TestStavelessFutharkTransformsRunesToletters(t *testing.T) {
// From Old Norse text in Hög runestone.
const content = "ᛍ╮ו⸜ᛁ╮⸍◟:ו◟╮:╵╮⸜:⸌ᛁ⸍:◟ᛁ⸍⸝:╵⸍ᛁ⸜:וᛁ⸜⸝:⸝ᛍ:ˏ◟╮:ᛍᛁ◟וᛁ:⸝ᛙ⸍ᛁʀ:ˏ◟╮ו◟:╵ᛁ⸜⸝:⸝╵ˏᛁ╮◟⸜:⸝ᛍ:⸝⸍:ᛍ╮ו⸌⸝ᛙ"
const expected = "kuþniutr þru sun lit rita stin þina ak bru kirþi aftiʀ bruþr sina asbiurn ak at kuþlaf"
result := stavelessfuthark.RunesToLetters(content)

if result != expected {
t.Error("Did not transform runes to letters. Received", result, "expected ", expected)
}
}
48 changes: 48 additions & 0 deletions stavelessfuthark/letters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package stavelessfuthark

func getLetterMapping() map[string]string {
return map[string]string{
"a": "⸝",
"á": "⸝",
"b": "ˏ",
"c": "╵",
"d": "⸍",
"ð": "ו",
"e": "ᛁ",
"é": "ᛁ",
"f": "ᛙ",
"g": "ᛍ",
"h": "ᚽ",
"i": "ᛁ",
"í": "ᛁ",
"j": "ᛁ",
"k": "ᛍ",
"l": "⸌",
"m": "⠃",
"n": "⸜",
"o": "ˎ",
"ó": "ˎ",
"p": "ˏ",
"q": "ᛍ",
"r": "◟",
"R": "⡄",
"s": "╵",
"t": "⸍",
"þ": "ו",
"u": "╮",
"ú": "╮",
"v": "╮",
"w": "╮",
"x": "╵",
"y": "╮",
"ý": "╮",
"z": "╵",
"å": "ˎ",
"ä": "⸝",
"æ": "⸝",
"ö": "ˎ",
"ø": "ˎ",
"ǫ": "ˎ",
" ": ":",
}
}
23 changes: 23 additions & 0 deletions stavelessfuthark/runes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package stavelessfuthark

func getRuneMapping() map[string]string {
return map[string]string{
"ᛙ": "f",
"╮": "u",
"ו": "þ",
"ˎ": "o",
"◟": "r",
"ᛍ": "k",
"ᚽ": "h",
"⸜": "n",
"ᛁ": "i",
"⸝": "a",
"╵": "s",
"⸍": "t",
"ˏ": "b",
"⠃": "m",
"⸌": "l",
"⡄": "R",
":": " ",
}
}
15 changes: 15 additions & 0 deletions stavelessfuthark/stavelessfuthark.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package stavelessfuthark

import (
"github.com/stscoundrel/riimut-go/internal/transform"
)

func LettersToRunes(content string) string {
letterMapping := getLetterMapping()
return transform.Transform(content, letterMapping)
}

func RunesToLetters(content string) string {
runeMapping := getRuneMapping()
return transform.Transform(content, runeMapping)
}
25 changes: 25 additions & 0 deletions stavelessfuthark/stavelessfuthark_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package stavelessfuthark

import (
"testing"
)

func TestTransformsLettersToRunes(t *testing.T) {
const content = "aábcdðeéfghiíjklmnoópqrRstþuúvwxyýzåäæöøǫþ "
const expected = "⸝⸝ˏ╵⸍וᛁᛁᛙᛍᚽᛁᛁᛁᛍ⸌⠃⸜ˎˎˏᛍ◟◟╵⸍ו╮╮╮╮╵╮╮╵ˎ⸝⸝ˎˎˎו:"
result := LettersToRunes(content)

if result != expected {
t.Error("Did not transform letters to runes. Received", result, "expected ", expected)
}
}

func TestTransformsRunesToletters(t *testing.T) {
const content = "ᛙ╮וˎ⡄ᛍᚽ⸜ᛁ⸝╵⸍ˏ⠃⸌⡄:"
const expected = "fuþoRkhniastbmlR "
result := RunesToLetters(content)

if result != expected {
t.Error("Did not transform runes to letters. Received", result, "expected ", expected)
}
}

0 comments on commit edca32b

Please sign in to comment.