alpancs / quranize

transform transliteration to Quran text

Home Page:https://pkg.go.dev/github.com/alpancs/quranize

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoDoc Build Status codecov

Quranize

Quranize provides Alquran in Go representation. Original source of Alquran is taken from http://tanzil.net in XML format.

Quranize can transform alphabet into arabic using fast and efficient algorithm: suffix-tree for indexing and dynamic programming for parsing.

Documentation

https://godoc.org/github.com/alpancs/quranize

Example

Here is a minimal example.

package main

import (
  "fmt"

  "github.com/alpancs/quranize"
)

func main() {
  q := quranize.NewDefaultQuranize()
  quran := quranize.NewQuranSimpleEnhanced()

  encodeds := q.Encode("alhamdulillah hirobbil 'alamin")
  fmt.Println(encodeds)
  // Output: [الحمد لله رب العالمين]

  locations := q.Locate(encodeds[0])
  fmt.Println(locations)
  // Output: [{1 2 0} {10 10 10} {39 75 13} {40 65 10}]

  suraName, _ := quran.GetSuraName(locations[0].GetSura())
  fmt.Println(suraName)
  // Output: الفاتحة

  aya, _ := quran.GetAya(locations[0].GetSura(), locations[0].GetAya())
  fmt.Println(aya)
  // Output: الْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ
}

Related Project

https://github.com/alpancs/quranize-service

About

transform transliteration to Quran text

https://pkg.go.dev/github.com/alpancs/quranize

License:MIT License


Languages

Language:Go 100.0%