Você está na página 1de 5

Poetry Expert System

Ahmad T. Al-Taani, Sallam Abualhaija Susanne Ramadan, Izza Abuhaija


Department of Computer Science Department of English Language and Literature
Yarmouk University Yarmouk University
Irbid, Jordan Irbid, Jordan
ahmadta@yu.edu.jo; paix84@yahoo.com sxr30@hotmail.com,
blackiris21@yahoo.com

Abstract complication to some extent which might lead to


This paper aims at shedding light on an important field of misunderstanding by ordinary people; therefore, a poem
literature which is poetry. The computer expert system merges its sometimes is just like a dilemma which needs a poetry expert who
codes with some wide knowledge of several poems. Using puts the reader on the line and makes him read between the lines.
linguistics and statistical stylistics facilitates dealing with any Furthermore, poetry passes through a historical life cycle; Old,
unexpected poem; hence the user is asked simply to count some Medieval, Renaissance, Romanticism, Victorian, Modern and
repeated lines and stanzas, or to find out some canonical figures Postmodern; each of which has common features that add a flavor
of speech; for instance: rhyme and similes; or even to search for to the period, as well as an influence on specific categories;
some marked punctuations. Apparently, the methodology enables paintings, drama, stage, poetry, and else.
any person with a normal knowledge of poetry to go through
some explicit questions in order to end up with a title and an In fact, Middle ages that span roughly from the 4th century And
author's name for the unseen chosen poem. The project aspires a last till 15th century are significant due to their deviation from the
prosperous interdisciplinary future of both computers and poetry path of classical learning in the Renaissance. Initially, it is the age
and hopefully, users will be able to learn about any unknown that renders under the influence of the Anglo-Saxon and the
poem to them easy. Normans; therefore; it has Romance and chivalry aspects along
with the didactic form due to Christianity effects.
Categories and Subject Descriptors Renaissance age, which extends from the late of the 16th century
I.7.5 [Document Capture]: Document analysis till the beginning of the 17th century, embodies the revival of the
classics, so early modern English is characterized by some
important forms: sonnets, metaphysical and cavalier; which
General Terms require highly elevated language. This prior age is penetrated by
Experimentations, Algorithms, Performance. the vivid imagination of the Romantics whose emphasis is based
on Nature and individual in simple and spontaneous dictions.
Keywords Later on, the two world wars force poetry to go into a Modern age
Poetry, Expert Systems, Knowledge Representation. that has some pessimistic aspects and a touch of reality sooner
replaced by a chaos world of postmodernity.

1 INTRODUCTION Actually, a helping tool that gives a hand to an English literature


language student will displace a heavy load of his shoulders, and
Recently, a computer machine has not only become a tool helping plain him the way into the deep sea of a poem not only its shores.
humans in their everyday life, but also imitating and sometimes
substituting humans themselves. Accordingly, it is not uncommon Converting poetry human expert’s knowledge and experience into
to wedge the computer static brainless machine into a passionate production rules consisting of if’s and then’s results a powerful
sensitive field like poetry, on the contrary; this merging produces students’ companion that gives poem analysis and explanation
a stronger basement to be followed. whenever asked to. As if each student is walking along with his
poetry professor all the time, imagine future professors!
Poetry doesn’t have an obvious meaning, because it is an abstract
word which carries the writers’ feelings and thoughts to the
audience using mainly the language. However, it is not a regular 2 RELATED WORK
language, but rather the language of paradox, similes, and Automatic generation of texts is a major research work in Natural
metaphors. Actually, such artistic tools might add to the poem a Language Processing field, in particular generating poetry for
different purposes.
Permission to make digital or hard copies of all or part of this work for Pablo Gervas is one of the pioneers in this branch; one of his
personal or classroom use is granted without fee provided that copies are major works is automatic poetry generation, specialized in
not made or distributed for profit or commercial advantage and that Spanish poetry, and the system is called ASPERA [1]; which is a
copies bear this notice and the full citation on the first page. To copy more complicated issue than the ordinary text, as poetry adds
otherwise, or republish, to post on servers or to redistribute to lists,
requires prior specific permission and/or a fee. some challenges that must be considered, such as; a specification
ICICS’12, April 3–5, 2012, Irbid, Jordan. of formal requirements that define a correct poem under the
Copyright 2012 ACM 978-1-4503-1327-8/04/2012…$10.00. literary classical methods, appropriate management for extensive
vocabulary, and correct combination of words that matches the to the rhyme, or depending on the grammatical attributes to form
user's requirements as well as the metric rules. a sentence that is fitted to the rhyme as well.
Then, the author explained the general formal rules of the Spanish The system’s output is a kind of suitable lyrics that harmonize
poetry, and demonstrated the method of selecting the proper with the input melodies.
words among the existing vocabulary, yet fitting these words into
a suitable metric structure. Another interesting variety in dealing with poetry is done by M.
A. Ismail et al. [4], where authors have presented an expert
ASPERA is a forward reasoning rule-based system that obtains system that enables the user to enter an Arabic poem which the
inputs from the user about some required specifications like system tests its harmony, if it is correct, then the system finds the
mood, settings, rhyme, length of the poem and the degree of proper bahr to which it belongs and converts it into the Arud
formality. Using these input elements, the system searches the form, but if it is incorrect the system highlights the incorrect
existing knowledge base about the most suitable words and positions.
ascertains specific facts, whereas some rules inside the system are
responsible for associating the user’s desires with the available The proposed system makes decisions based on automated
previous knowledge about vocabulary and poems’ specifications. reasoning, and contains three modules; consultation, editor and
The system produces a draft poem to be validated or modified by the knowledge base. The editor is the section that interacts with
the user, then after a linguistic analysis, the final version of the the user, and enables one entering a new poem as well as
poem is outputted. modifying an existing one.

The previous author, Pablo Gervas, has designed also another Another important section is the knowledge base which consists
novel system; WASP [2], which is also a forward reasoning rule- of two parts; knowledge part1 which contains the heuristic rules
based system that takes as input data a set of words and a set of to convert Arabic poetry to Arud form, and the part2 is a
verse patterns, yet gives the output as a set of verses. The system deterministic knowledge base concerned about converting the
has two modes for generating verses; generating either Arud form into a binary form by representing the vowel by “1”
unrestricted verses, or poems based on predefined structures; and the consonant by “0”.
romance, cuarteto, or terceto. [2] Finally, the consultation module is responsible to figure out the
Initially, a set of evaluation rules for the input data are introduced, bahr that suits the poem entered by the end user, and interacts
then, these rules are transformed into corresponding construction with both knowledge base parts.
rules applied on an initial set of data; which consists of a set of The system is implemented using Prolog language, and tested
words chosen by the poet, and the way to combine them. These upon 20 poems, yet it is concluded that the system is capable to
two parameters play an important role in the goodness of the final check the harmony of the Arabic poems, and it is considered as a
result. tool explaining the steps to check the harmony, it also shows the
WASP is capable of generating a poem with no knowledge about binary form of the input poem.
grammar or meaning based on some heuristic approach; each
verse maintains a pattern that describes particular information 3 THE POETRY EXPERT SYSTEM
about the speech and number of words.
First, the algorithm chooses a word randomly, appends this word 3.1 System Components
to a draft verse, and uses the pattern to figure out that the verse The expert system forms a helping tool, as figure 1
still satisfies its required length of syllables. If the draft verse shows. It consists of an interface that interacts with the user;
satisfies this requirement, then the system iterates or else it who is an English literature student or a little bit familiar
changes the chosen word.
with essential poetry terms, a knowledge base, which is
On the other hand, Hugo R. Oliveira et al. [3] have demonstrated represented by production rules, contains the poems and
a new approach for generating text based on rhythm. In this poets and a forward reasoning inference engine.
method, the authors have explained a computer program that
inputs a MIDI file which is converted to an ABC musical note,
next a specific melody extractor section converts this ABC file
into a list of Meters which forms a list of Notes.
Knowledge
Yet, another part Melody analyzer is responsible for specifying Base
the note position inside the Meter, its strength and whether it is
corresponding to the end part or suitable to begin a new rhyme. 1) Poem name
After that, a special module chooses appropriate words from a 2) Poet name
predefined database based on the syllable strength of the word, Input 3)Explanation
Inference Output
and fits them in the melody rhythm. poem
Engine
Finally, the system originates the ABC file again to contain the
lyrics suitable for the first input MIDI file.
Choosing the vocabulary of words is considered a great concern
to obtain good results, so the system demonstrates 3 strategies to Figure 1: Expert System Components
do so; picking words randomly and trying to match them with the Hence, the user is asked for some characteristics about the poem,
rhyme, using predefined sentence templates then matching them and when these characteristics become similar for a group of
poems, then extended stylistics features are being requested to
differentiate among them. Using CLIPS shell makes the interface Table 1: Example of the classification Process
clumsy, where it consists of some questions asked depending on
user’s answers. Question Possible answer(s)
Is it a shape poem? Yes/ No
As a result, the system displays the poem's title, and author, and
provides a brief explanation if the user wants about the reasoning How many Stanzas are x: x is any integer number
behind these results. there in the poem?
What is the Rhyme of aabb, ababcdcdefefgg, …
3.2 The Knowledge Base the Poem
The knowledge base includes 64 poems that are listed in the table How many times the x: x is any integer number
in Appendix B, each poem is numbered and its number is used
instead of its name for simplicity. Acquisition of the knowledge
word “and” is
base depends mainly on the old syllabus of the poetry course for repeated in the
B.A. English Literature Students in Yarmouk University. poem?

3.3 The Classification Phase 4 EXPERIMENTS


The project methodology is based on some linguistics stylistics The knowledge base consists of 64 poems classified into a
basically and sometimes it also deals with statistical stylistics number of clusters from which a representative sample is selected
features. Apparently; using such features allows any reader to to be used in a user evaluation process. Hence, a sample of size 36
answer simple questions regardless the level of poetic knowledge is chosen randomly, in a way that the sample covers all clusters,
one might have. In fact, the system since the very beginning starts where each cluster includes poems that share common features.
asking the user some questions about the poem stylistics features;
such as counting the number of “I” in the poem, or the number of The system is tested in three phases each of which targeted
lines. Most of the questions depend on words that the poem different users in order to obtain the best accuracy of the results
contains; however, the main specialized question is about the and to examine how useful the project is in giving the answers to
rhyme of the poem, that is something assumed all students in this the students, so, three groups of English Literature students in
level can do. Some of the questions on which the classification Yarmouk university have contributed in the user evaluation of the
based are given in the Table 1 below. system; where each group evaluated 12 poems.

At the beginning, the poems are clustered based on some common 4.1 Results
features, and the questions that are being asked by the system
aims at specifying these clusters. We go from general questions The system is tested by Yarmouk University English Literature
towards more specialized ones not only to distinguish the clusters students in a Poetry course for the undergraduate. In order to
but also the poems within. obtain more accuracy, the students were chosen randomly form
three classes, 12 students from each class, and thus examined 12
Then, the user inputs the answers directly to the system; e.g the poems on the system.
rhyme of the poem as a set of strings with case insensitive, and
these answers lead the classification process by excluding some Moreover, it is worth to mention that the poems were unseen by
possibilities, and outweighing some others; a Shakespearean the students, this way the students are put in the real atmosphere
sonnet has a predefined rhyme(s) with the same number of lines for which the system is suggested, assuming that a student has a
12 always, the system then ask about something else to poem that is unseen, and this student did know nothing about the
differentiate among poems; such as the number of occurrences of name or the author of the poem, then with the help of this system,
the word "I". the poem is revealed.

Choosing the words occurrences in the poem is not done So, the testing process is performed on three levels, 12 poems in
arbitrarily, however, the stylistics features of the poem are taken each level and the results are shown in the Table 2.
into account, beside the major distinctions among the poems in Table 2: Testing results
the same cluster.
Correct Incorrect Total
In order to eliminate the variation if the question is about the
major topic of the poem, the system gives a set of distinct choices, Group1 9 3 12
this way the user chooses the same word stored in the rule; e.g. if Group2 10 2 12
the poet is talking mainly about winter characteristics, then the
Group3 9 3 12
system gives the word 'winter' in the choices, so if the user had
'nature' in mind, he will finally choose from the list what is Total 28 8 36
appropriate.
Each time the user inputs an answer, the system limits the set of For reliability insurance, results are compared to a domain expert
poems corresponding to these features, until the only poem is classification, where the expert is a professor in the English
found. After it is defined, the system retrieves the poem's Literature department in Jordan University of Science and
information from the knowledgebase, and outputs its name and Technology. The professor was asked to classify the same sample
author, then ask the user if he wishes for explanation, if yes, the of poems set for evaluation, then the professor, depending on
system gives a brief description of the reasoning led to this result. experience, defined the potential name of the poem and its author;
hitting most of them and missing few.
Table 3 shows the results obtained from the system versus these PS = 0.78, and PH =0.67
from the human expert where it is obvious that the human the
classification correctness is almost the same for the two, with a Now, we want to test the hypothesis that H0 : PH > PS
significant difference in time. Calculating the estimate standard error
Table 3: Domain Expert vs. System (es) = √(PH * (1- PH)/n = 0.013
Correct Incorrect Total Time (in And the Z actual Value (Z actual) = (PS – PH)/es = 8.46
minutes)
Z critical value when (alpha = 0.05) = 1.68 (i.e. the confident
Poetry 28 8 36 30 interval = 95%)
Expert So, the actual value is greater than the critical value, and this
System means that we reject the null hypothesis. Rejecting the null
Domain 24 12 36 60 hypothesis proves the result that the probability of an expert
system classifies poems properly is greater than that of a human
Expert
expert’s.
Total 52 20 72
5 CONCLUSION AND FUTURE WORK
4.2 Analysis As a conclusion, the Poetry expert system has proven a good
performance and it forms indeed a helping tool for the students in
Figure 2 shows the relation between the performance of the their journey within poetry filed.
domain expert and the poetry expert system in terms of valid
classifications. Moreover, this system is available for the students at anytime,
while the real professor might be not, so it is a good idea if the
students some day in the future own such a tool that helps them in
their understanding and is available all the time.
In future, this project might be developed to help in other difficult
fields in English literature and other languages as well, such as
providing an expert system of novels that guides the students to
enrich their understanding while reading novels, and gives some
analytical views.

5.1.1.1.1 REFERENCES
[1] Gervas P., “An expert system for the composition of the Spanish
poetry”, Journal of Knowledge-Based Systems, Volume 14, Issues
3-4, Pages 181-188, June 2001.
[2] Gervas P., “WASP: Evaluation of Different Strategies for the
Figure 2: Domain Expert vs. Expert System Automatic Generation of Spanish Verse”, University of
Birmingham, 2000.
Obviously, the figure shows an improvement in the valid [3] Oliveira H., Cardoso F., and Pereira F., “Tra-la-Lyrics: An approach
classification made by the system, especially that the time to generate text based on rhythm”, University of London, 2005.
required by the system is half less, indicating the goodness of the [4] Ismail M., Eladawy M., Keshk H. and Saleh S., “Expert System for
rules used in the system. Testing the Harmony of Arabic Poetry”,
<http://www.eladawy.com/resources/Others/Expert%20System%20f
Now, calculating the recall and precision values based on the or%20Testing%20the%20harmony%20of%20Arabic%20poetry.pdf
Table 3, we have: Precision = 78%, and Recall = 100% > Last visited: October 15th, 2010.
[5] Oliveira H., “Automatic generation of poetry: an overview”,
So, as we see that the precision of the Poetry system based on the Universidade de Coimbra, 2009.
experiments done is only 78% which is not very significant, [6] Manurung H., Ritchie G. and Thompson H., “A Flexible Integrated
however, this low value of precision is mainly because of the Architecture For Generating Poetic Texts”, The University of
inaccurate answers that the students made during the test phases, Edinburgh, 2000.
for example, in counting the number of a specific word, which is [7] Francisco V. and Gervas P., “Automated Mark Up of Aơ ective
not a difficult thing to do, but to count a word in a poem among Information in English Texts”, Springer-Verlag, Berlin, 2006.
many words, one might not pay attention for one occurrence [8] Giarratano J. and Riley G., Expert Systems: Principles and
which then leads to a wrong answer. Programming, Thomson Course Technology, Canada, 2005.
[9] Hieatt A. Kent, Poetry in English: An Anthology, Oxford University
Furthermore, applying the T test, based on Table 3, to examine Press, UK, 1987.
the performance of the system, we have:
PS : the probability that the system answers correctly
PH : the probability that the human answers correctly
Appendix A: End Notes 6 The Tyger
7 The Lamb
Antonym: a word of opposite meaning, the usual antonym
8 Elizabeth Barrett Sonnet 43 - How do I love thee? Let
of good is bad, < 2011 Merriam-Webster, 9 Sonnet 14 - If thou must love me, let
Browning
http://www.merriam- 10 The Cry Of The Children
webster.com/dictionary/antonym?show=0&t=1296933902> 11 Robert Porphyria's Lover
Concrete Poetry: Poetry that draws much of its power from 12 Browning My Last Duchess
the way the text appears situated on the page. The actual 13 Lord Byron She Walks In Beauty
shape of the lines of text may create a swan's neck, an altar, 14 Solitude
a geometric pattern, or a set of wings, which in some direct 15 Rupert Brooke The Soldier
way connects to the meaning of the words. Also called 16 Life
"shaped poetry" and "visual poetry," . The object here is to 17 Passion
present each poem as a different shape. It may appear on the 18 Charlotte Bronte Parting
page, on glass, stone, wood, or other materials. < Dr. L. Kip 19 Regret
Wheeler 1998-2011, 20 Pleasure
http://web.cn.edu/kwheeler/index.html> 21 Come, Walk With Me
Emily Bronte
22 Love and Friendship
Epigram: A very short, witty poem: “Sir, I admit your 23 Samuel Epigram
general rule,/That every poet is a fool,/But you yourself may 24 Coleridge The Rime Of The Ancient Mariner
serve to show it,/That every fool is not a poet.” (Samuel 25 Geoffrey The General Prologue
Taylor Coleridge). <ibid> 26 Holy Sonnet X: Death Be Not Proud
John Donne
Refrain: A line or group of lines that is repeated throughout 27 A Valediction: Forbidding Mourning
28 Mac Flecknoe
a poem, usually after every stanza. <ibid> John Dryden
29 Epigram on Milton
Rhyme: The occurrence of the same or similar sounds at 30 T.S.Eliot The Love Song of J. Alfred Prufrock
the end of two or more words. When the rhyme occurs in a 31 Elegy Written In A Country
Thomas Gray
final stressed syllable, it is said to be masculine: cat/hat, 32 Ode on the Death of a Favourite Cat,
desire/fire, observe/deserve. When the rhyme occurs in a 33
Thomas Hardy
The Man He Killed
final unstressed syllable, it is said to be feminine: 34 Ah, Are You Digging On My Grave?
longing/yearning. The pattern of rhyme in a stanza or poem 35 George Herbert Easter Wings
is shown usually by using a different letter for each final 36 Robert Herrick TO THE VIRGINS, TO MAKE MUCH
sound. In a poem with an aabba rhyme scheme, the first, 37 John Keats Ode To A Nightingale
second, and fifth lines end in one sound, and the third and 38 Rudyard Kipling The Ballad of East and West
fourth lines end in another. <ibid> 39 Richard Lovelace To Althea, From Prison
40 To Lucasta, Going To The Wars
Sonnet: A lyric poem that is 14 lines long. Italian (or 41 Andrew Marvell To His Coy Mistress
Petrarchan) sonnets are divided into two quatrains and a six- 42 C. Marlowe The Passionate Shepherd To His
line “sestet,” with the rhyme scheme abba abba cdecde (or 43 John Milton On His Blindness
cdcdcd). English (or Shakespearean) sonnets are composed 44 Alexander Pope Epigram Engraved on the Collar of a
of three quatrains and a final couplet, with a rhyme scheme 45 Essay on Man
of abab cdcd efef gg. English sonnets are written generally 46 Ezra Pound In a Station of the Metro
in iambic pentameter. <ibid> 47 Christina Goblin Market
Stanza: Two or more lines of poetry that together form one 48 Sonnet 130: My mistress' eyes are
William
of the divisions of a poem. The stanzas of a poem are 49 Sonnet 18: Shall I compare thee to a
Shakespeare
usually of the same length and follow the same pattern of 50 Sonnets LX: Like as the waves make
meter and rhyme. <ibid> 51 Sir Philip Sidney Come Sleep, O Sleep! The Certain
52 Percy Bysshe Ozymandias
Arud Science: Defines the harmony of Arabic poetry 53 Shelley Ode To The West Wind
based on repeating the syllable phonetic by a certain pattern. 54 Edmund Spenser Sonnet 75
<ref. 4> 55 Dylan Thomas Do Not Go Gentle Into That Good
56 Lord Alfred The Lotos-Eaters
Bahr: Arud science defines 16 different patterns called
57 Tennyson Mariana
Bahr. <ref. 4>
58 I Wandered Lonely As A Cloud
William
Appendix B: The Knowledge Base 59 My Heart Leaps Up
Wordsworth
60 The world is too much with us
no. Poet Poem 61 Sir Thomas Farewell Love and All Thy Laws
1 This Little Bag 62 Wyatt My Galley, Charged with
Jane Austin
2 When Stretch'd on One's Bed 63 W. Butler Yeats Sailing To Byzantium
3 The Sick Rose 64 Anonymous Beowulf
4 William Blake The Chimney Sweeper (Innocence)
5 The Chimney-Sweeper (Experience)