Language examples library

Examples

Short texts chosen to show a specific linguistic phenomenon: clitics, hamzas, dialects, numbers, negation, simple sentences and difficult constructions. Open any example in its tool to see the result.

Text tokenization

BeginnerArabic

Words with prefixes and suffixes

وبكتابهم وجدنا الحلَّ، فسيكتبونها للطلاب غداً.

Notice that «وبكتابهم» and «فسيكتبونها» each count as one word by whitespace, while each carries several units. Try showing the segmentations.

Open in tool
IntermediateArabic

Mixed social media text

أطلقنا اليوم #مختبر_اللغة 🎉 التفاصيل على https://dlarabic.com/nlp-lab/ وراسلونا على info@example.com

The lab classifies each token: hashtag, emoji, link, email, Arabic word.

Open in tool
IntermediateArabic

Numbers, dates and abbreviations

قدّم د. علي ورقته يوم ٢٠٢٤/٠٥/١٢ الساعة 10:30 أمام 3.5 آلاف مشارك.

The sentence should not be split at «د.» or at the decimal point in 3.5.

Open in tool
BeginnerEnglish

English contractions and punctuation

Dr. Smith didn't arrive. The U.S. team won 3-1! Wasn't that great?

Abbreviations such as Dr. and U.S. must not end a sentence.

Open in tool
AdvancedArabic

A small corpus for trying BPE

كتب كاتب كتاب كتابة مكتوب مكتبة مكتبات كاتبون كاتبات يكتبون تكتب نكتب الكتاب الكتابة المكتبة

Enter this text in BPE mode with 15 merges and watch «كت», then «كتا», then «كتاب» appear.

Open in tool

Text preprocessing

BeginnerArabic

A diacritized line of poetry

الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني ... وَالسّيفُ وَالرّمحُ وَالقرْطاسُ وَالقَلَمُ

A line by al-Mutanabbi (4th century AH, public domain). Try removing the diacritics and compare the length of the text before and after.

Open in tool
BeginnerArabic

A social media text

جمييييل جداااا 😍😍 الـــمـــطعم هذا!!! ١٠/١٠ أنصح فيه

Tatweel, repeated letters, emojis, Eastern Arabic digits, repeated punctuation.

Open in tool
IntermediateArabic

Forms of hamza, yaa and taa

أحمد وإبراهيم وآمنة ذهبوا إلى المدرسة الابتدائية في مدينة الكوفه، وقالوا: هذى مسألة سهلة

Compare the hamza unification policies, and notice the effect of «ى→ي» and «ة→ه» on «إلى» and «مسألة».

Open in tool
IntermediateArabic

Persian letters in an Iraqi text

گالي: چان ماكو وقت، روح ويّا صديقك وجيب الکتاب

The Persian letters option changes «ک» to «ك». It turns «گ» and «چ» into «ك» and «ج», which helps search but erases a sound distinction in the dialect.

Open in tool
BeginnerEnglish

Noisy English text

OMG!!! This is sooooo GOOD 😂😂 visit http://example.com NOW!!! 100% recommended

Try lowercase, punctuation, URL cleaning and repetition reduction.

Open in tool

Morphological analysis

BeginnerArabic

The family of the root ك ت ب

كتب كاتب الكاتبون مكتوب مكتبة المكتبات كتابة يكتبون استكتب

Compare Light10 (which removes affixes) with ISRI (which tries to reach the root).

Open in tool
IntermediateArabic

Heavily affixed words

وبالمعلمين فسيكتبونها والمدرستان لمكتباتهم وسنعلمهم

Notice the effect of the minimum stem length in Light10.

Open in tool
IntermediateArabic

Ambiguous words

علم ذهب وجد عين فصل

Each word here allows more than one analysis without diacritics. The tool does not choose a single analysis without context.

Open in tool
AdvancedArabic

Weak and doubled roots

قال يقول وعد يعد رمى يرمي مدّ استمرار

Pattern algorithms stumble on weak and doubled letters; notice the confidence of the results.

Open in tool
BeginnerEnglish

English stemming

running runs runner connected connection connections happily studies

The lab uses a small rule-based English stemmer for illustration, not the full Porter algorithm.

Open in tool

Part-of-speech tagging

BeginnerArabic

A simple verbal sentence

كتب الطالب الدرس في المكتبة.
Open in tool
BeginnerArabic

A nominal sentence

العلم نور والجهل ظلام.
Open in tool
IntermediateArabic

Pronouns and particles

هو لم يذهب إلى الجامعة لأنه كان مريضاً.
Open in tool
IntermediateArabic

Words with ambiguous tags

ذهب الرجل يبحث عن الذهب في الجبل.

The word «ذهب» is once a verb and once a noun. Notice how the lab uses «ال» as evidence of a noun.

Open in tool
BeginnerEnglish

English sentence

The young researcher quickly wrote a new paper about Arabic dialects.
Open in tool

Named entity recognition

BeginnerArabic

A short news item

زار الدكتور أحمد الساعدي جامعة بغداد يوم الأحد 12 أيار 2024 والتقى رئيس الجامعة في الساعة 10:30 صباحاً.

Try the extraction methods one at a time: patterns, lists, trigger words.

Open in tool
BeginnerArabic

Iraqi provinces and cities

انطلقت القافلة من البصرة مروراً بالناصرية والكوت ووصلت إلى الموصل ثم أربيل.

Notice «بالناصرية» being caught after the ب is separated.

Open in tool
IntermediateArabic

Organizations, numbers and amounts

أعلنت وزارة التعليم العالي والبحث العلمي تخصيص 250 مليون دينار لدعم 40 مشروعاً بحثياً بنسبة 15%.
Open in tool
BeginnerArabic

Contact details

للاستفسار راسلوا info@example.org أو زوروا https://example.org/contact أو اتصلوا على +964 770 000 0000

The numbers here are a clearly fake example (zeros).

Open in tool
BeginnerEnglish

English news sentence

On Monday, Dr. Sarah Lee from the University of Oxford met officials in Baghdad and London.
Open in tool

Sentiment analysis

BeginnerArabic

A positive opinion

الخدمة ممتازة والموظفون لطفاء جداً، تجربة رائعة وأنصح بها.
Open in tool
BeginnerArabic

A negative opinion

التطبيق بطيء ومليء بالأخطاء، تجربة سيئة ومخيبة.
Open in tool
IntermediateArabic

The effect of negation

المكان ليس جميلاً، والطعام لم يكن لذيذاً، لكن السعر مناسب.

Notice how a negation particle flips the effect of the next word, and how the result of each sentence differs.

Open in tool
IntermediateArabic

Iraqi dialect

الأكل كلش طيب والمكان خوش، بس الخدمة مو زينة.

Dialect words in the lexicon: كلش (intensifier), خوش, زين, مو (negation).

Open in tool
AdvancedArabic

Sarcasm (an expected failure case)

يا سلام! انقطعت الكهرباء للمرة العاشرة اليوم، شيء رائع فعلاً.

An example of the limits of the lexicon method: «رائع» ("wonderful") counts as positive even though the meaning is negative.

Open in tool
BeginnerEnglish

English mixed review

The camera is excellent, but the battery is terrible and it's not cheap.
Open in tool

Arabic dialect identification

IntermediateArabic

A sentence in MSA

كيف حالك؟ أنا متعب جداً اليوم وأريد أن أذهب إلى البيت الآن.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool
IntermediateArabic

A sentence in Iraqi Arabic

شلونك؟ آني كلش تعبان اليوم وأريد أروح للبيت هسه.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool
IntermediateArabic

A sentence in Egyptian Arabic

إزيك؟ أنا تعبان أوي النهارده وعايز أروح البيت دلوقتي.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool
IntermediateArabic

A sentence in Gulf Arabic

شلونك؟ أنا وايد تعبان اليوم وأبي أروح البيت الحين.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool
IntermediateArabic

A sentence in Levantine Arabic

كيفك؟ أنا كتير تعبان اليوم وبدي روح ع البيت هلق.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool
IntermediateArabic

A sentence in Moroccan Arabic

لاباس عليك؟ أنا عيان بزاف اليوم وبغيت نمشي للدار دابا.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool
IntermediateArabic

A sentence in Algerian Arabic

واش راك؟ راني عيان بزاف اليوم وحاب نروح للدار درك.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool
IntermediateArabic

A sentence in Tunisian Arabic

شنحوالك؟ آنا تعبان برشا اليوم ونحب نروح للدار توا.

The same sentence in eight versions: compare the indicative words (now, very, I want) in each dialect. Written for the lab; needs review by a native speaker.

Open in tool

Syntactic parsing

BeginnerArabic

Verb, subject and object

كتبَ الطالبُ الدرسَ

A hand-parsed tree.

Open in tool
BeginnerArabic

An intransitive verb and a prepositional phrase

ذهبَ أحمدُ إلى الجامعةِ

The preposition attaches to the noun it governs with the case relation, and that noun attaches to the verb with the obl relation.

Open in tool
BeginnerArabic

Adjective

قرأتِ الطالبةُ كتاباً مفيداً
Open in tool
IntermediateArabic

A nominal sentence (subject and predicate)

العلمُ نورٌ

In UD, the predicate is the root of a nominal sentence, and the subject depends on it with the nsubj relation.

Open in tool
IntermediateArabic

Genitive construction (idafa)

بابُ البيتِ مفتوحٌ

The second term of the idafa attaches to the first with the nmod relation.

Open in tool
IntermediateArabic

Coordination

سافرَ الطبيبُ والمهندسُ إلى بغدادَ

In UD, the second conjunct attaches to the first with the conj relation, and the conjunction attaches to the second conjunct with the cc relation.

Open in tool
BeginnerArabic

An adjective of a genitive noun

يدرسُ الطلابُ في المكتبةِ الكبيرةِ
Open in tool
AdvancedArabic

Negation

لم يحضرِ المديرُ الاجتماعَ

The negation particle «لم» is tagged PART and attaches to the verb with the advmod relation, as in the UD_Arabic-PADT treebank.

Open in tool
BeginnerEnglish

English SVO

The student wrote the lesson
Open in tool
IntermediateEnglish

English with adjective and PP

She reads a useful book in the library
Open in tool

Semantic embeddings

BeginnerArabic

Analogies: king − man + woman

ملك رجل امرأة

With the teaching vectors this gives «ملكة» ("queen") because the dimensions were designed for it. With trained vectors the result is less regular.

Open in tool
BeginnerArabic

The words closest to «طبيب» ("doctor")

طبيب
Open in tool
IntermediateArabic

Capital and country

بغداد العراق القاهرة

Iraq − Baghdad + Cairo ≈ Egypt in the teaching dimensions.

Open in tool

Semantic similarity

BeginnerArabic

Synonyms that share no letters

الطبيب والممرضة في المستشفى

Jaccard is low because the words differ, while semantic similarity with the teaching vectors is high because «طبيب/دكتور» and «مستشفى/مستوصف» are close in them.

Open in tool
BeginnerArabic

Different forms of the same word

ذهب الطلاب إلى المكتبات

Stemming and character n-grams raise the lexical similarity here.

Open in tool
IntermediateArabic

Two opposite sentences

أحب هذا الفيلم كثيراً

High lexical and semantic similarity despite the opposite opinions: a known limitation.

Open in tool
BeginnerArabic

Two words with a spelling mistake

مكتبه

The Levenshtein distance between «مكتبه» and «مكتبة» = 1.

Open in tool
BeginnerEnglish

English paraphrase

The cat sat on the mat
Open in tool

Machine translation

BeginnerArabic

A simple sentence

الطالب يقرأ الكتاب في المكتبة

Notice that the word order in the output is Arabic, not English.

Open in tool
BeginnerArabic

A verbal sentence

كتب الباحث بحثاً جديداً

The verb comes first in Arabic and the subject first in English. And «كتب» without diacritics may be a verb or the plural of «كتاب», and the dictionary does not see the context, so it picks the first recorded meaning.

Open in tool
BeginnerEnglish

English to Arabic

the new student reads a big book

The adjective comes after the noun in Arabic.

Open in tool
IntermediateArabic

An idiom

ضرب عصفورين بحجر

Translating the words one by one does not give the idiomatic meaning (to kill two birds with one stone).

Open in tool

Text summarization

BeginnerArabic

Arabic language processing

تواجه معالجة اللغة العربية تحديات خاصة لا تظهر بالدرجة نفسها في الإنجليزية. أول هذه التحديات غياب التشكيل في أغلب النصوص، مما يجعل الكلمة الواحدة تحتمل عدة قراءات. والتحدي الثاني غنى الصرف العربي، إذ تُشتق من الجذر الواحد عشرات الكلمات بأوزان مختلفة. كما تلتصق حروف العطف والجر والضمائر بالكلمة، فتحتاج الأنظمة إلى تجزئة دقيقة قبل التحليل. ويزيد تعدد اللهجات من صعوبة المهمة، لأن النصوص المنشورة على الإنترنت تخلط الفصحى باللهجات. وقد ساعدت النماذج المدربة مسبقاً مثل AraBERT وCAMeLBERT وMARBERT على تحسين النتائج في كثير من المهام. لكن الموارد الموسومة لبعض اللهجات ما زالت قليلة، وهذا يجعل بناء مدونات جديدة أولوية بحثية.

A text written for the lab. Try TF-IDF and TextRank with two sentences and compare the choice.

Open in tool
IntermediateArabic

The history of machine translation

بدأت الترجمة الآلية مبكراً في تاريخ الحوسبة. ففي عام 1954 عرضت جامعة جورجتاون وشركة IBM تجربة ترجمت فيها عشرات الجمل من الروسية إلى الإنجليزية. وبعد سنوات من التفاؤل، صدر تقرير ALPAC عام 1966 فانتقد بطء التقدم، فتراجع التمويل. ثم ظهرت في التسعينيات الترجمة الإحصائية التي تتعلم من نصوص متوازية بدلاً من القواعد المكتوبة يدوياً. وفي منتصف العقد الثاني من هذا القرن انتقلت الأنظمة إلى الشبكات العصبية. وأصبحت معمارية Transformer التي نُشرت عام 2017 أساس أغلب أنظمة الترجمة الحديثة. وما زالت الترجمة من اللهجات العربية وإليها أصعب من الترجمة من الفصحى بسبب قلة البيانات.

A text written for the lab from well-known historical facts.

Open in tool
BeginnerArabic

The Tigris and Euphrates rivers

ينبع نهرا دجلة والفرات من مرتفعات تركيا ويجريان نحو الجنوب الشرقي. يمر الفرات في سوريا قبل أن يدخل العراق، بينما يدخل دجلة العراق من الشمال. وتقع بغداد على ضفتي دجلة، وتقع مدن مثل الرمادي والفلوجة على الفرات. ويلتقي النهران في جنوب العراق قرب القرنة ليكوّنا شط العرب. ويصب شط العرب في الخليج العربي بعد أن يمر بمدينة البصرة. وقد قامت على ضفاف النهرين حضارات قديمة عديدة في بلاد الرافدين.

A short geographical text written for the lab.

Open in tool
BeginnerEnglish

Tokenization in modern NLP

Tokenization is the first step in most NLP pipelines. Early systems split text on spaces and punctuation, which works reasonably well for English. Languages with rich morphology, such as Arabic and Turkish, produce very large vocabularies under this approach. Subword methods such as BPE and WordPiece address this problem by learning frequent character sequences from a corpus. Modern transformer models rely on these subword vocabularies, which typically contain tens of thousands of units. The choice of tokenizer affects model size, speed and accuracy, especially for under-resourced languages.

Original paragraph written for the lab.

Open in tool

Experiment space

BeginnerArabic

A processing pipeline for search

وقال المُعلِّمونَ: إنّ المكتبـــات الجديدة رائعة جداً!! 😊 زوروها في ٢٠٢٤

A pipeline suited to a search system: cleaning, then normalization, then stopword removal, then light stemming.

Open in tool
IntermediateArabic

A processing pipeline for sentiment analysis

المطعم مو زين أبداً 😡 بس الموظفين كلش لطفاء!!!

We neither remove stopwords nor stem, so we do not lose negation and intensifiers.

Open in tool

Iraqi dialect lab

BeginnerArabic

An everyday conversation

شلونك عيني؟ شكو ماكو؟ هسه وصلت من الدوام وكلش تعبان.

Iraqi words: شلون, عيني, شكو ماكو, هسه, الدوام, كلش.

Open in tool
BeginnerArabic

At the market

بيش هذا الكيلو؟ هواية غالي، نزّل شوية بالسعر.

بيش = how much, هواية = a lot, شوية = a little.

Open in tool
IntermediateArabic

Appointments

باچر الصبح نروح ويّا خالي للجامعة، بس إذا ماكو زحمة.

باچر = tomorrow, ويّا = with, ماكو = there is no.

Open in tool
IntermediateArabic

questions

ليش ما جيت البارحة؟ وين چنت؟ شنو صار؟

ليش = why, وين = where, چنت = I was, شنو = what.

Open in tool