Skip to content

Commit

Permalink
Merge pull request #28 from stscoundrel/feature/younger-futhark-variants
Browse files Browse the repository at this point in the history
Feature/younger futhark variants
  • Loading branch information
stscoundrel authored Jun 19, 2022
2 parents fea7fc9 + 33e19ae commit 5c3b543
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dotnet - Build
name: .NET - Build

on: [pull_request]

Expand All @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet: ['5.0.x', '6.0.x']
dotnet: ['6.0.x']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dotnet - Pack
name: .NET - Pack

on: [pull_request]

Expand All @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet: ['5.0.x', '6.0.x']
dotnet: ['6.0.x']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dotnet - Test
name: .NET - Test

on: [pull_request]

Expand All @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet: ['5.0.x', '6.0.x']
dotnet: ['6.0.x']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ Console.WriteLine(latinText); // "auk tani karþi kristna"
```


Rune variants in Younger Futhark:

Younger Futhark comes with long branch (Danish) and short twig (Norwegian & Swedish) variants.
```csharp

using Riimut;

string letters = "aábcdðeéfghiíjklmnoópqrstþuúvwxyýzåäæöøǫþ";
YoungerFuthark youngerFuthark = new YoungerFuthark();

// Comes with named methods per style.
string longBranch = youngerFuthark.LettersToLongBranchRunes(letters);
string shortTwig = youngerFuthark.LettersToShortTwigRunes(letters);

Console.WriteLine(longBranch); // ᛅᛅᛒᛋᛏᚦᛁᛁᚠᚴᚼᛁᛁᛁᚴᛚᛘᚾᚢᚢᛒᚴᚱᛋᛏᚦᚢᚢᚢᚢᛋᚢᚢᛋᚢᛅᛅᚢᚢᚢᚦ"
Console.WriteLine(shortTwig); // ᛆᛆᛒᛌᛐᚦᛁᛁᚠᚴᚽᛁᛁᛁᚴᛚᛘᚿᚢᚢᛒᚴᚱᛌᛐᚦᚢᚢᚢᚢᛌᚢᚢᛌᚢᛆᛆᚢᚢᚢᚦ
// Instance can also be created with default style. Then LettersToRunes will use that style.
YoungerFuthark youngerFutharkLongBranch = new YoungerFuthark(YoungerFuthark.Variant.LongBranch);
YoungerFuthark youngerFutharkShortTwig = new YoungerFuthark(YoungerFuthark.Variant.LongBranch);

// Or you can switch the style of instance at will.
youngerFutharkLongBranch.EnableShortTwig();
youngerFutharkShortTwig.EnableLongBranch();

```


#### What's in the name?

"Riimut" is the Finnish word for "runes".
57 changes: 54 additions & 3 deletions src/Mappings/YoungerFutharkMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Riimut.Mappings
{
internal class YoungerFutharkMapping
{
private readonly static Dictionary<string, string> LettersToRunesMapping = new Dictionary<string, string>()
private readonly static Dictionary<string, string> LettersToLongBranchRunesMapping = new Dictionary<string, string>()
{
{"a", ""},
{"á", ""},
Expand Down Expand Up @@ -50,6 +50,52 @@ internal class YoungerFutharkMapping
{" ", ":"},
};


private readonly static Dictionary<string, string> LettersToShortTwigRunesMapping = new Dictionary<string, string>()
{
{"a", ""},
{"á", ""},
{"b", ""},
{"c", ""},
{"d", ""},
{"ð", ""},
{"e", ""},
{"é", ""},
{"f", ""},
{"g", ""},
{"h", ""},
{"i", ""},
{"í", ""},
{"j", ""},
{"k", ""},
{"l", ""},
{"m", ""},
{"n", ""},
{"o", ""},
{"ó", ""},
{"p", ""},
{"q", ""},
{"r", ""},
{"s", ""},
{"t", ""},
{"þ", ""},
{"u", ""},
{"ú", ""},
{"v", ""},
{"w", ""},
{"x", ""},
{"y", ""},
{"ý", ""},
{"z", ""},
{"å", ""},
{"ä", ""},
{"æ", ""},
{"ö", ""},
{"ø", ""},
{"ǫ", ""},
{" ", ":"},
};

private readonly static Dictionary<string, string> RunesToLettersMapping = new Dictionary<string, string>()
{
{"", "f"},
Expand All @@ -75,9 +121,14 @@ internal class YoungerFutharkMapping
{"", "R"},
{":", " "},
};
public static Dictionary<string, string> GetLettersToRunesDictionary()
public static Dictionary<string, string> GetLettersToLongBranchRunesDictionary()
{
return LettersToLongBranchRunesMapping;
}

public static Dictionary<string, string> GetLettersToShortTwigRunesDictionary()
{
return LettersToRunesMapping;
return LettersToShortTwigRunesMapping;
}

public static Dictionary<string, string> GetRunesToLettersDictionary()
Expand Down
2 changes: 1 addition & 1 deletion src/Riimut.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<PackageId>Riimut</PackageId>
<Version>1.0.4</Version>
<Authors>stscoundrel / Sampo Silvennoinen</Authors>
Expand Down
42 changes: 39 additions & 3 deletions src/YoungerFuthark.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Riimut.Mappings;

namespace Riimut
{
public class YoungerFuthark : Dialect
{
public enum Variant
{
LongBranch,
ShortTwig
}

Variant RuneStyle;

public YoungerFuthark(Variant style = Variant.LongBranch)
{
RuneStyle = style;
}

public void EnableLongBranch()
{
RuneStyle = Variant.LongBranch;
}

public void EnableShortTwig()
{
RuneStyle = Variant.ShortTwig;
}

public string LettersToRunes(string content)
{
Dictionary<string, string> mapping = YoungerFutharkMapping.GetLettersToRunesDictionary();
Dictionary<string, string> mapping = RuneStyle == Variant.LongBranch ? YoungerFutharkMapping.GetLettersToLongBranchRunesDictionary() : YoungerFutharkMapping.GetLettersToShortTwigRunesDictionary();

return Riimut.Transform.WithDictionary(content, mapping);
}
Expand All @@ -19,5 +41,19 @@ public string RunesToLetters(string content)

return Riimut.Transform.WithDictionary(content, mapping);
}

public string LettersToLongBranchRunes(string content)
{
Dictionary<string, string> mapping = YoungerFutharkMapping.GetLettersToLongBranchRunesDictionary();

return Riimut.Transform.WithDictionary(content, mapping);
}

public string LettersToShortTwigRunes(string content)
{
Dictionary<string, string> mapping = YoungerFutharkMapping.GetLettersToShortTwigRunesDictionary();

return Riimut.Transform.WithDictionary(content, mapping);
}
}
}
6 changes: 3 additions & 3 deletions tests/RiimutTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -19,8 +19,8 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Riimut.csproj" />
<ItemGroup>
<ProjectReference Include="..\src\Riimut.csproj" />
</ItemGroup>

</Project>
89 changes: 81 additions & 8 deletions tests/YoungerFutharkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,49 @@ namespace RiimutTest
public class YoungerFutharkTests
{
[Fact]
public void TransformsLettersToYoungerFuthark()
public void DefaultLetterTransform()
{
string letters = "aábcdðeéfghiíjklmnoópqrstþuúvwxyýzåäæöøǫþ";
string runes = "ᛅᛅᛒᛋᛏᚦᛁᛁᚠᚴᚼᛁᛁᛁᚴᛚᛘᚾᚢᚢᛒᚴᚱᛋᛏᚦᚢᚢᚢᚢᛋᚢᚢᛋᚢᛅᛅᚢᚢᚢᚦ";

Dialect youngerFuthark = new YoungerFuthark();
YoungerFuthark youngerFuthark = new YoungerFuthark();
string result = youngerFuthark.LettersToRunes(letters);

Assert.Equal(runes, result);
}

[Fact]
public void TransformsLettersToLongBranchRunes()
{
string letters = "aábcdðeéfghiíjklmnoópqrstþuúvwxyýzåäæöøǫþ";
string runes = "ᛅᛅᛒᛋᛏᚦᛁᛁᚠᚴᚼᛁᛁᛁᚴᛚᛘᚾᚢᚢᛒᚴᚱᛋᛏᚦᚢᚢᚢᚢᛋᚢᚢᛋᚢᛅᛅᚢᚢᚢᚦ";

YoungerFuthark youngerFuthark = new YoungerFuthark();
string result = youngerFuthark.LettersToLongBranchRunes(letters);

Assert.Equal(runes, result);
}

[Fact]
public void TransformsLettersToShortTwigRunes()
{
string letters = "aábcdðeéfghiíjklmnoópqrstþuúvwxyýzåäæöøǫþ";
string runes = "ᛆᛆᛒᛌᛐᚦᛁᛁᚠᚴᚽᛁᛁᛁᚴᛚᛘᚿᚢᚢᛒᚴᚱᛌᛐᚦᚢᚢᚢᚢᛌᚢᚢᛌᚢᛆᛆᚢᚢᚢᚦ";

YoungerFuthark youngerFuthark = new YoungerFuthark();
string result = youngerFuthark.LettersToShortTwigRunes(letters);

Assert.Equal(runes, result);
}

[Fact]
public void TransformsTextContentToYoungerFuthark()
{
// From Old Groms runestone.
string letters = "auk tani karþi kristna";
string runes = "ᛅᚢᚴ:ᛏᛅᚾᛁ:ᚴᛅᚱᚦᛁ:ᚴᚱᛁᛋᛏᚾᛅ";

Dialect youngerFuthark = new YoungerFuthark();
YoungerFuthark youngerFuthark = new YoungerFuthark();
string result = youngerFuthark.LettersToRunes(letters);

Assert.Equal(runes, result);
Expand All @@ -34,13 +58,17 @@ public void TransformsTextContentToYoungerFuthark()
[Fact]
public void TransformsRunesToLetters()
{
string runes = "ᚠᚢᚦᚬᚱᚴᚼᚽᚾᚿᛁᛅᛆᛋᛌᛏᛐᛒᛘᛚᛦ:";
// Both long branch & short twig should produce same letters.
string longBranchRunes = "ᚠᚢᚦᚬᚱᚴᚼᚽᚾᚿᛁᛅᛆᛋᛌᛏᛐᛒᛘᛚᛦ:";
string shortTwigRunes = "ᚠᚢᚦᚬᚱᚴᚽᚽᚿᚿᛁᛆᛆᛌᛌᛐᛐᛒᛘᛚᛦ:";
string letters = "fuþorkhhnniaassttbmlR ";

Dialect youngerFuthark = new YoungerFuthark();
string result = youngerFuthark.RunesToLetters(runes);
YoungerFuthark youngerFuthark = new YoungerFuthark();
string result1 = youngerFuthark.RunesToLetters(longBranchRunes);
string result2 = youngerFuthark.RunesToLetters(shortTwigRunes);

Assert.Equal(letters, result);
Assert.Equal(letters, result1);
Assert.Equal(letters, result2);
}

[Fact]
Expand All @@ -50,10 +78,55 @@ public void TransformsRuneContentToLatinLetters()
string runes = "ᛅᚢᚴ:ᛏᛅᚾᛁ:ᚴᛅᚱᚦᛁ:ᚴᚱᛁᛋᛏᚾᛅ";
string letters = "auk tani karþi kristna";

Dialect youngerFuthark = new YoungerFuthark();
YoungerFuthark youngerFuthark = new YoungerFuthark();
string result = youngerFuthark.RunesToLetters(runes);

Assert.Equal(letters, result);
}

[Fact]
public void StyleVariantSettersChangeRuneset()
{
string letters = "aábcdðeéfghiíjklmnoópqrstþuúvwxyýzåäæöøǫþ";
string expectedLongBranchRunes = "ᛅᛅᛒᛋᛏᚦᛁᛁᚠᚴᚼᛁᛁᛁᚴᛚᛘᚾᚢᚢᛒᚴᚱᛋᛏᚦᚢᚢᚢᚢᛋᚢᚢᛋᚢᛅᛅᚢᚢᚢᚦ";
string expectedShortTwigRunes = "ᛆᛆᛒᛌᛐᚦᛁᛁᚠᚴᚽᛁᛁᛁᚴᛚᛘᚿᚢᚢᛒᚴᚱᛌᛐᚦᚢᚢᚢᚢᛌᚢᚢᛌᚢᛆᛆᚢᚢᚢᚦ";

YoungerFuthark youngerFuthark = new YoungerFuthark();

// Expected to use long branch as default.
string longBranchResult = youngerFuthark.LettersToRunes(letters);

// Change to short twig.
youngerFuthark.EnableShortTwig();
string shortTwigResult = youngerFuthark.LettersToRunes(letters);

// Switch back to long branch
youngerFuthark.EnableLongBranch();
string secondLongBranchResult = youngerFuthark.LettersToRunes(letters);

Assert.Equal(expectedLongBranchRunes, longBranchResult);
Assert.Equal(expectedShortTwigRunes, shortTwigResult);
Assert.Equal(expectedLongBranchRunes, secondLongBranchResult);
}

[Fact]
public void ConstructorsDefineRuneSetToUse()
{
string letters = "aábcdðeéfghiíjklmnoópqrstþuúvwxyýzåäæöøǫþ";
string expectedLongBranchRunes = "ᛅᛅᛒᛋᛏᚦᛁᛁᚠᚴᚼᛁᛁᛁᚴᛚᛘᚾᚢᚢᛒᚴᚱᛋᛏᚦᚢᚢᚢᚢᛋᚢᚢᛋᚢᛅᛅᚢᚢᚢᚦ";
string expectedShortTwigRunes = "ᛆᛆᛒᛌᛐᚦᛁᛁᚠᚴᚽᛁᛁᛁᚴᛚᛘᚿᚢᚢᛒᚴᚱᛌᛐᚦᚢᚢᚢᚢᛌᚢᚢᛌᚢᛆᛆᚢᚢᚢᚦ";

YoungerFuthark youngerFutharkDefault = new YoungerFuthark();
YoungerFuthark youngerFutharkLongBranch = new YoungerFuthark(YoungerFuthark.Variant.LongBranch);
YoungerFuthark youngerFutharkShortTwig = new YoungerFuthark(YoungerFuthark.Variant.ShortTwig);

string defaultResult = youngerFutharkDefault.LettersToRunes(letters);
string shortTwigResult = youngerFutharkShortTwig.LettersToRunes(letters);
string longBranchResult = youngerFutharkLongBranch.LettersToRunes(letters);

Assert.Equal(expectedLongBranchRunes, defaultResult);
Assert.Equal(expectedShortTwigRunes, shortTwigResult);
Assert.Equal(expectedLongBranchRunes, longBranchResult);
}
}
}

0 comments on commit 5c3b543

Please sign in to comment.