Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

verses - fork

priv/static/corpus/kural/kural.livemd

verses - fork

Mix.install([
  {:jason, "~> 1.4"}
])

Section

defmodule Gita do
  @external_resource "/home/albert/vyasa/priv/static/corpus/gita/chapters.json"

  @verse "/home/albert/vyasa/priv/static/corpus/gita/chapters.json"
         |> File.read!()
         |> Jason.decode!()

  def verse(chapter_number) when is_integer(chapter_number) do
    @verse
  end

  def verse(_), do: nil
end

Gita.verse(1)
defmodule Kural do
  @external_resource "/home/albert/vyasa/priv/static/corpus/kural/thirukkural.json"

  @verse "/home/albert/vyasa/priv/static/corpus/kural/thirukkural.json"
         |> File.read!()
         |> Jason.decode!()

  def verse() do
    @verse
  end

  def verse(_), do: nil
end

Kural.verse()

Kural Parser

  • Adikarams 132
  • Iyal 13
  • Pal 3
Kural.verse()
|> Map.get("kural")
|> Enum.group_by(& &1["paul_name"])

# |> Enum.map(fn {p, v} ->
#   {p,
#    v
#    |> Enum.group_by(& &1["iyal_name"])
#    |> Enum.map(fn {i, v} ->
#      {i,
#       v
#       |> Enum.group_by(& &1["adikaram_name"])
#     }
#   end)
#    |> Enum.map(fn {i, v} ->
#      {i,
#       v
#       |> Enum.sort(&(List.first(elem(&1, 1))["Number"] <= List.first(elem(&2, 1))["Number"]))}
#    end)}
# end)
# |> Enum.into(%{})

# # |> Enum.group_by(& &1["paul_name"])
# |> length()
# into chapter, into verses
verse =
  "/home/putra/vyasa/priv/static/corpus/gita/verse.json"
  |> File.read!()
  |> Jason.decode!()
  |> Enum.group_by(&amp; &amp;1["chapter_number"])
  |> Enum.map(fn {c, v} ->
    {c,
     v
     |> Enum.sort(&amp;(&amp;1["verse_number"] <= &amp;2["verse_number"]))}
  end)
  |> Enum.into(%{})

# |> Jason.encode!()

# File.write!("sorted_verse.json", verse)
# File.cwd()