Algorithm comparisons

Compare

Run two different processing pipelines on the same text and see the difference word by word, then review the comparison tables between opposing algorithms.

Compare two pipelines

Runs in your browser

Light stemming versus root extraction

ItemLight10 light stemmerISRI root stemmer
FamilyTraditional algorithmTraditional algorithm
DefinitionA light stemmer for Arabic that removes a limited number of common prefixes and suffixes without trying to reach the root, and improves retrieval compared with full words and roots.An Arabic stemmer that tries to reach the root without a root dictionary, by removing prefixes and suffixes and then matching the word with morphological patterns according to its length.
OutputsStemAn approximate root
ComplexityO(1) per wordO(1) per word
Strengths
  • Simple and very fast
  • Effective in information retrieval
  • Needs no root dictionary
  • Groups the different morphological forms of the same root
Cons
  • Does not handle broken plurals («كتب» and «كتاب» are different stems)
  • May remove original letters that look like suffixes (such as the yaa in «عربي» → «عرب»)
  • Fails on weak and doubled roots and on loanwords
  • A root groups distant meanings, which sometimes hurts retrieval precision

Frequency-based versus graph-based summarization

ItemTF-IDF weightingThe TextRank algorithm
FamilyTraditional algorithmTraditional algorithm
DefinitionA weight for a word in a document that rises with its frequency there (TF) and falls with how common it is in other documents (IDF), highlighting distinctive words.A graph-based ranking algorithm that applies the PageRank idea to sentences (or words) to extract the most important ones without supervision.
OutputsA weight for each (word, document)A score for each sentence, and a summary
ComplexityO(N) in the text sizeO(S²) to build the graph + the PageRank iterations
Strengths
  • Simple and effective
  • The basis of classic search engines
  • Unsupervised and needs no data
  • Captures sentence centrality
Cons
  • Sees neither meaning nor order
  • Favours long, similar sentences
  • May choose sentences that repeat the same meaning

Subwords: BPE versus WordPiece

ItemByte Pair EncodingWordPiece tokenization
FamilyTraditional algorithmTraditional algorithm
DefinitionA subword tokenization algorithm that learns its vocabulary from a corpus by repeatedly merging the most frequent adjacent pair of symbols, producing units between a character and a word.A subword tokenization method used by BERT models: the vocabulary is built by choosing the merges that raise the likelihood of the training data, and a word is encoded by longest match from the left.
OutputsA list of merges and subword vocabulary, and the encoding of each wordA list of pieces such as «ال ##معلم ##ون»
ComplexityNaive training is O(N·M), where N is the corpus size and M the number of merges; faster implementations existEncoding is O(n²) in the word length with a naive implementation
Strengths
  • Solves the out-of-vocabulary (OOV) problem
  • Controllable vocabulary size
  • Suits morphologically rich languages
  • Fast and deterministic encoding
  • Used in BERT and its Arabic derivatives
Cons
  • The units are statistical and may not match morphological boundaries
  • Depends on the corpus it was trained on
  • Depends entirely on the trained vocabulary
  • Greedy encoding is not always optimal

Word similarity versus character n-gram similarity

ItemJaccard coefficientCharacter n-gram similarity
FamilyTraditional algorithmTraditional algorithm
DefinitionThe similarity of two sets, equal to the size of their intersection divided by the size of their union.Comparing two texts by their sets of character n-grams (for example trigrams), which captures the similarity of morphological forms and simple spelling mistakes.
OutputsA number between 0 and 1A number between 0 and 1
ComplexityO(|A|+|B|) with hash tablesO(L) in the number of characters
Strengths
  • Simple and intuitive
  • Needs no resources
  • Robust to morphology and spelling mistakes
Cons
  • Does not see synonyms
  • Affected by morphological forms without stemming
  • Does not understand meaning
  • May raise the similarity of words with distant meanings

Pattern-and-list entities versus a trained model

ItemPattern and list-based entity recognitionTransformer entity recognition
FamilyResource-basedDeep learning
DefinitionDetecting entities with regular expressions for regular forms (dates, times, amounts and percentages) and with lists of known names and trigger words (titles and organization heads).Fine-tuning a pretrained language model (such as CAMeLBERT or AraBERT) on data tagged in BIO format to classify each token into an entity type.
OutputsA list of entities (text, type, position, method)Entities with their types
ComplexityO(n·p), where p is the number of patternsTransformer inference is O(n²) in the segment length
Strengths
  • High accuracy on regular patterns
  • Needs no training
  • The highest accuracy today
  • Finds unknown names from context
Cons
  • Does not find names that are not in the lists
  • Entity boundaries found through trigger words are approximate
  • Needs tagged data and computing resources
  • Less transparent

Lexicon-based sentiment versus a trained model

ItemLexicon-based sentiment analysisTransformer sentiment classification
FamilyResource-basedDeep learning
DefinitionComputing a text's polarity by adding up word values from a sentiment lexicon, with rules for negation, intensification and contrast.Fine-tuning a language model pretrained on Arabic text (such as MARBERT or CAMeLBERT-DA) to classify sentiment in Modern Standard Arabic and the dialects.
OutputsA score, a verdict and the influential wordsA class and probabilities
ComplexityO(n)Transformer inference is O(n²)
Strengths
  • Needs no training data
  • Fully explainable
  • Understands context and compound negation better
  • Handles the dialects if trained on them
Cons
  • Does not understand sarcasm, context or figurative language
  • Lexicon coverage is limited and varies across domains and dialects
  • Usually needs a GPU and labelled data
  • May inherit biases from the data

Traditional, lexical and trained

FamilyWhat do you need?Number of algorithms in the libraryIn this lab
Traditional algorithmRules, counting and arithmetic, with no need for a trained model17Runs in the browser
Resource-basedReady-made dictionaries, lists and linguistic rules11Runs in the browser
Machine learningA statistical model that needs labeled training data8Explanation only, or through an external engine enabled by the admin
Deep learningA neural network with trained weights9Explanation only, or through an external engine enabled by the admin
Large language modelA huge pre-trained generative model0Explanation only, or through an external engine enabled by the admin