Documentation ¶
Overview ¶
Package garabic provides a set of functions for Arabic text processing in golang
Index ¶
- Constants
- func IsArabic(input string) bool
- func IsArabicLetter(ch rune) bool
- func Normalize(input string) string
- func RemoveHarakat(input string) string
- func Shape(input string) string
- func SpellNumber(input int) string
- func Tashkeel(input string) string
- func ToArabicDigits(input string) string
- func ToEnglishDigits(input string) string
Examples ¶
Constants ¶
View Source
const ( //Alef => ا Alef = '\u0627' //AlefMad => آ AlefMad = '\u0622' //AlefHamzaAbove => أ AlefHamzaAbove = '\u0623' //AlefHamzaBelow إ AlefHamzaBelow = '\u0625' //Yae => ي Yae = '\u064A' //DotlessYae => ى DotlessYae = '\u0649' //TehMarbuta => ة TehMarbuta = '\u0629' //Hae => ه Hae = '\u0647' //AlefWaslah ٱ / Waslah is considered part of harakat/تَشْكِيل ? AlefWaslah = '\u0671' )
Normalizable letters alef/Yae/Hae
Variables ¶
This section is empty.
Functions ¶
func IsArabicLetter ¶
IsArabicLetter checks if the letter is arabic
Example ¶
fmt.Println(IsArabicLetter('ص'))
Output: true
func Normalize ¶
Normalize will prepare an arabic text to search and index
Example ¶
normalized := Normalize("أحمد") fmt.Println(normalized)
Output: احمد
func RemoveHarakat ¶
RemoveHarakat will remove harakat from arabic text
Example ¶
normalized := RemoveHarakat("سَنواتٌ") fmt.Println(normalized)
Output: سنوات
func SpellNumber ¶
SpellNumber will transform a number into a readable arabic version
Example ¶
numberInWords := SpellNumber(100) fmt.Println(numberInWords)
Output: مئة
func ToArabicDigits ¶
ToArabicDigits will convert english numbers to arabic numbers in text
Example ¶
fmt.Println(ToArabicDigits("عام 2021"))
Output: عام ٢٠٢١
func ToEnglishDigits ¶
ToEnglishDigits will convert arabic numbers to english numbers in text
Example ¶
fmt.Println(ToEnglishDigits("عام ٢٠٢١"))
Output: عام 2021
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.