-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from abdnh/ar
Add Arabic
- Loading branch information
Showing
5 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/// Simple Arabic stemmer based on lunr.ar.js from https://github.com/MihaiValentin/lunr-languages | ||
use pipeline::Pipeline; | ||
use regex::Regex; | ||
|
||
pub fn make_pipeline() -> Pipeline { | ||
Pipeline { | ||
queue: vec![ | ||
("stemmer-ar".into(), stemmer), | ||
], | ||
} | ||
} | ||
|
||
fn stemmer(token: String) -> Option<String> { | ||
lazy_static! { | ||
static ref DIACRITICS: Regex = Regex::new("[\u{064b}-\u{065b}]").unwrap(); | ||
static ref ALEFS: Regex = Regex::new("[\u{0622}\u{0623}\u{0625}\u{0671}\u{0649}]").unwrap(); | ||
} | ||
// remove elongating character | ||
let token = token.replace('\u{0640}', ""); | ||
// remove diacritics | ||
let token = DIACRITICS.replace(&token, ""); | ||
// replace all variations of alef (آأإٱى) to a plain alef (ا) | ||
let token = ALEFS.replace(&token, "\u{0627}"); | ||
|
||
Some(token.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
استعار جحا مرة آنية من جاره وعندما أعادها له أعاد معها آنية صغيرة | ||
فسأله جاره لماذا أعدت مع أنيتي آنية صغيرة يا جحا؟ | ||
فقال له جحا: إنّ آنيتك ولدت في الأمس آنية صغيرة وإنّها الآن من حقك، فرح الرجل وأخذ الطنجرة ودخل بيته، | ||
وبعد فترة من الزمان ذهب جحا إلى جاره وطلب منه أنية أخرى، فأعطاه جاره ما طلب، مرّ وقت طويل ولم يُعد جحا الآنية، | ||
فذهب جاره إلى بيته ليطلبها منه، فاستقبله جحا باكياً منتحباً، | ||
فقال له الرجل: مالي أراك باكياً يا جحا؟!! فقال له جحا وهو يبكي إنّ آنيتك توفيت بالأمس يا صاحبي، | ||
فقال له جاره وهو غاضب: وكيف لآنيةٍ أن تموت يا رجل؟!! فقال جحا أتصدق أنّ إناء قد يلد ولا تصدق أنّه قد يموت؟! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
استعار | ||
جحا | ||
مرة | ||
انية | ||
من | ||
جاره | ||
وعندما | ||
اعادها | ||
له | ||
اعاد | ||
معها | ||
انية | ||
صغيرة | ||
فساله | ||
جاره | ||
لماذا | ||
اعدت | ||
مع | ||
انيتي | ||
انية | ||
صغيرة | ||
يا | ||
جحا؟ | ||
فقال | ||
له | ||
جحا: | ||
ان | ||
انيتك | ||
ولدت | ||
في | ||
الامس | ||
انية | ||
صغيرة | ||
وانها | ||
الان | ||
من | ||
حقك، | ||
فرح | ||
الرجل | ||
واخذ | ||
الطنجرة | ||
ودخل | ||
بيته، | ||
وبعد | ||
فترة | ||
من | ||
الزمان | ||
ذهب | ||
جحا | ||
الى | ||
جاره | ||
وطلب | ||
منه | ||
انية | ||
اخرى، | ||
فاعطاه | ||
جاره | ||
ما | ||
طلب، | ||
مر | ||
وقت | ||
طويل | ||
ولم | ||
يعد | ||
جحا | ||
الانية، | ||
فذهب | ||
جاره | ||
الى | ||
بيته | ||
ليطلبها | ||
منه، | ||
فاستقبله | ||
جحا | ||
باكيا | ||
منتحبا، | ||
فقال | ||
له | ||
الرجل: | ||
مالي | ||
اراك | ||
باكيا | ||
يا | ||
جحا؟!! | ||
فقال | ||
له | ||
جحا | ||
وهو | ||
يبكي | ||
ان | ||
انيتك | ||
توفيت | ||
بالامس | ||
يا | ||
صاحبي، | ||
فقال | ||
له | ||
جاره | ||
وهو | ||
غاضب: | ||
وكيف | ||
لانية | ||
ان | ||
تموت | ||
يا | ||
رجل؟!! | ||
فقال | ||
جحا | ||
اتصدق | ||
ان | ||
اناء | ||
قد | ||
يلد | ||
ولا | ||
تصدق | ||
انه | ||
قد | ||
يموت؟! |