Skip to content

linguatools/ArabicStemmer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arabic Stemmer

Tokenizer and stemmer for Arabic based on Lucene's UTF-8 tokenizer and ArabicStemmer. The ArabicStemmer is Lucene's implementation of the light stemmer (Light10) from the following paper:

Leah S. Larkey, Lisa Ballesteros, and Margaret E. Connell. Light Stemming for Arabic Information Retrieval.

Installation

You need a Java 8 Runtime Engine. For standalone use from the command line download the jar file ArabicStemmer-1.0.jar. It includes all dependencies. Then type

java -jar ArabicStemmer-1.0.jar

to see the available command line options.

Command line usage

All input files must be UTF-8 encoded plain text files. They may contain lines with a single XML-style tag, for instance:

<s>
كأس العالم لكرة القدم 2014 هي الدورة العشرون من بطولات كأس العالم لكرة القدم، أقيمت في قارة أمريكا الجنوبية بعد أن حدد الاتحاد الدولي لكرة القدم نظام التناوب بين
 القارات وحدارة أمريكا الجنوبية لتقام فيها البطولة، ولم يطلب أي بلد الاستضافة سوى البرازيل، التي تقدمت بالملف في 31 يوليو 2007.
</s>

These tags (in the example <s> and </s>) are copied to the output, unless you specify the option -ignore-xml.

You have to specify if you want to tokenize, normalize or stem the input by using one of the commands tok, norm, or stem. Tokenization applies Lucene's StandardTokenizer, normalization additionally calls ArabicNormalizer, and stemming uses ArabicAnalyzer (which performs tokenization, normalization, and stemming). You can also normalize and stem an already tokenized input file with the command pretok.

Output format can be either txt or tsv:

  • txt: outputs only the (possibly normalized or stemmed) tokens, separated by a single white space.
  • tsv: outputs one token per line with three columns separated by a tab:
    1. token content as in the input (token-span substring of input)
    2. true or false specifying if the token is an indexable Term as defined by Lucene. Indexable terms are tokens that contain letters or numbers.
    3. depending on the command: same as i. for tok, normalized token for norm, stemmed token for stem or pretok.

If you want to build a DISCO word space with DISCOBuilder use the following options to preprocess your corpus files:

java -jar ArabicStemmer-1.0.jar stem -of tsv -i <INPUT_FILE> -o <OUTPUT_FILE>

This will produce an output file in DISCOBuilder's LEMMATIZED input format (using the stems as lemmas). Then, in the disco.config configuration file for DISCOBuilder set the parameters as follows:

inputFileFormat=LEMMATIZED
lemma=false
lemmaFeatures=true

Java API

You can also include the ArabicStemmer into your Java project. To tokenize or stem a string use the method Main.analyseString. The package uses version 5.1.0 of Lucene. See API docs (javadoc).

License

Apache License 2.0