
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
github.com/ahmedalkabir/garabic
this is fork will be activly maintained by Ahmed Alkabir (me).
A set of functions for Arabic text processing in golang
مكتبة برمجية توفر دوالاً للتعامل مع النصوص العربية في لغة برمجة go
⚠️ The library still under active development
⚠️ المكتبة لا تزال تحت التطوير
package main
import (
"fmt"
arabic "github.com/abdullahdiaa/garabic"
)
func main() {
normalized := arabic.RemoveHarakat("سَنواتٌ")
fmt.Println(normalized)
// Output:
// سنوات
}
Here's an example for printing Arabic text on an image:
مثال لطباعة نص عربي علي صورة:
without the library/ من غير استخدام المكتبة
using the library/ باستخدام المكتبة
package main
import (
"image"
"image/color"
"image/png"
"io/ioutil"
"log"
"os"
"github.com/abdullahdiaa/garabic"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
"golang.org/x/image/math/fixed"
)
func addLabel(img *image.RGBA, x, y int, label string) {
//Load font file
//You can download amiri font from this link: https://fonts.google.com/specimen/Amiri?preview.text=%D8%A8%D9%90%D8%A7%D9%84%D8%B9%D9%8E%D8%B1%D9%8E%D8%A8%D9%90%D9%91%D9%8A&preview.text_type=custom#standard-styles
b, err := ioutil.ReadFile("Amiri-Regular.ttf")
if err != nil {
log.Println(err)
return
}
ttf, err := opentype.Parse(b)
if err != nil {
log.Println(err)
return
}
//Create Font.Face from font
face, err := opentype.NewFace(ttf, &opentype.FaceOptions{
Size: 26,
DPI: 72,
Hinting: font.HintingNone,
})
d := &font.Drawer{
Dst: img,
Src: image.NewUniform(color.RGBA{120, 157, 243, 255}),
Face: face,
Dot: fixed.P(x, y),
}
d.DrawString(label)
}
func main() {
img := image.NewRGBA(image.Rect(0, 0, 700, 70))
addLabel(img, 40, 40, garabic.Shape("قِفا نَبكِ مِن ذِكرى حَبيبٍ وَمَنزِلِ **** بِسِقطِ اللِوى بَينَ الدَخولِ فَحَومَلِ"))
f, err := os.Create("printed_arabic_text.png")
if err != nil {
panic(err)
}
defer f.Close()
if err := png.Encode(f, img); err != nil {
panic(err)
}
}
Here's a benchmark for normalizing ~78K words on MBP i5 takes about ~45ms:
BenchmarkNormalizeBigText-4 25 45546613 ns/op 9275097 B/op 31 allocs/op
~45 ms
You can view detailed documentation here: GoDoc.
يمكنك مراجعة توثيق الكود و الاستخدام الخاص بكل دالة من خلال هذا الرابط: GoDoc.
There are many ways to contribute:
يمكنك المشاركة في تطوير المكتبة بأحد هذه الطرق:
View the changelog for the latest updates and changes by version.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.