Skip to content

Commit

Permalink
Transliteration table (#2)
Browse files Browse the repository at this point in the history
* adds transliteration_table function

* Bumps library version
  • Loading branch information
Efesto authored Mar 12, 2023
1 parent 223bde7 commit b72e791
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The package can be installed by adding `vasov` to your list of dependencies in `
```elixir
def deps do
[
{:vasov, "~> 0.1.0"}
{:vasov, "~> 0.2.0"}
]
end
```
Expand Down
9 changes: 7 additions & 2 deletions lib/vasov.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Vasov do
The transliteration implements the [streamlined system](https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1105090/ROMANIZATION_OF_BULGARIAN_with_examples.pdf)
officially adopted in Bulgaria.
"""
@bg_to_latin %{
@transliteration_table %{
"Р" => "R",
"з" => "z",
"Т" => "T",
Expand Down Expand Up @@ -86,10 +86,15 @@ defmodule Vasov do
|> normalize()
|> String.graphemes()
|> Enum.reduce("", fn
original, acc -> acc <> Map.get(@bg_to_latin, original, original)
original, acc -> acc <> Map.get(@transliteration_table, original, original)
end)
end

@doc """
Returns the transliteration table as a map
"""
def transliteration_table, do: @transliteration_table

defp normalize(text) do
text
|> normalize_state_name()
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Vasov.MixProject do
use Mix.Project

@source_url "https://github.com/Efesto/vasov"
@version "0.1.0"
@version "0.2.0"

def project do
[
Expand Down
6 changes: 6 additions & 0 deletions test/vasov_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ defmodule VasovTest do
assert expected == Vasov.transliterate_to_latin(original)
end
end

describe "transliteration_table/0" do
test "returns the transliteration table" do
assert %{"и" => "i", "И" => "I", "т" => "t"} = Vasov.transliteration_table()
end
end
end

0 comments on commit b72e791

Please sign in to comment.