项目作者: alpancs

项目描述 :
transform transliteration to Quran text
高级语言: Go
项目地址: git://github.com/alpancs/quranize.git
创建时间: 2018-05-26T05:35:13Z
项目社区:https://github.com/alpancs/quranize

开源协议:MIT License

下载


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.

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/alpancs/quranize"
  5. )
  6. func main() {
  7. q := quranize.NewDefaultQuranize()
  8. quran := quranize.NewQuranSimpleEnhanced()
  9. encodeds := q.Encode("alhamdulillah hirobbil 'alamin")
  10. fmt.Println(encodeds)
  11. // Output: [الحمد لله رب العالمين]
  12. locations := q.Locate(encodeds[0])
  13. fmt.Println(locations)
  14. // Output: [{1 2 0} {10 10 10} {39 75 13} {40 65 10}]
  15. suraName, _ := quran.GetSuraName(locations[0].GetSura())
  16. fmt.Println(suraName)
  17. // Output: الفاتحة
  18. aya, _ := quran.GetAya(locations[0].GetSura(), locations[0].GetAya())
  19. fmt.Println(aya)
  20. // Output: الْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ
  21. }

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