עיבוד שפות טבעיות - שיעור רביעי part of speech tagging
Post on 31-Dec-2015
59 Views
Preview:
DESCRIPTION
TRANSCRIPT
89-6801
עיבוד שפות טבעיות - שיעור רביעיPart of Speech Tagging
עידו דגן
המחלקה למדעי המחשב
אוניברסיטת בר אילן
89-6802
חלקי-הדיבור
~ קבוצות מילים המכונות "חלקי- 9מקובל למנות •דיבור":
(,adjective(,שם תואר )nounשם עצם )•(,verb(,פועל )numeral(,שם מספר )pronounכינוי )
(,preposition(,מלת יחס )adverbתואר הפועל )(.interjection(,מלת קריאה )conjunctionמלת חיבור )
אך זו רק חלוקה אחת•
89-6803
למה זה טוב?
parsingבסיס לניתוח •
( – אופן הביטוי של המילה:TTSיצירת קול )•רכבת/רכבת ––CONtent/conTENT, OBJect/objECT, DIScount/disCOUNT
•Chunking/partial parsing/identifing terms
•N-gram models for speech
•IR,MT
89-6804
איך מגדירים חלקי דיבר?
באופן מסורתי, ההגדרה של חלקי הדיבר מבוססת על •תכונות מורפולוגיות של המילה או על המילים
.distributional propertiesשמופיעות לידן בסמיכות באופן עקרוני, יש למילים מאותו חלק דיבר דמיון סמנטי, •
כלומר, הן מתארות איברים מאותן קבוצות למשל ,thought, table– אנשים, מקומות, דברים nounsשמות עצם ––
sisterbig, lazy תכונות, כמויות adjectivesשמות תואר – –quickly – מתארים אופן, מקום, זמן, איכות adverbsלואי פעולה – –eat, is, writeפעלים – אירועים, התרחשויות או מצבי קיום – –ויש גם מילות יחס, מילות איחוי ועוד...–
89-6805
דוגמא
The yinkish dripner blorked quastofically into the nindin with the pidibs.
• yinkish -adj nindin -noun• dripner -noun pidibs -noun• blorked -verb quastofically -adverb
• We determine the P.O.S of a word by the affixes that are attached to it and by the syntactic context (where in the sentence) it appears in.
89-6806
Open class vs. Closed class types
•Closed class הקבוצה שחבריה קבועים בדרך כלל, כמו – מילות יחס.
•Open class למשל, שמות עצם ופעלים: מילים חדשות –, לפקססto faxמתווספות לקבוצה
בקורפוסים שונים ייצפו מילים שונות מהקבוצה הפתוחה, •אבל אם הקורפוס גדול מספיק, סביר להניח שימצאו בהם
אותם מילים השייכות לקבוצה הסגורה.– function wordsמילים מהקבוצה הסגורה הן בדרך כלל •
– מילים קצרות בדרך , את of מילים השייכות לדקדוק כמוכלל המופיעות בתדירות גבוהה, ולהן תפקיד תחבירי חשוב.
89-6807
שמות עצם
• Nouns – take -s, 's, -ness, -ment, -er, affixes – Occur with determiners
(a,the,this,some…)– can be a subject of a sentence.
• Semantically: can be concrete – chair, train, or abstract – relationship.
eating, אכילה, לאכולאו שמות פעולה, למשל: •
89-6808
Types of Nouns
• Proper Nouns:– David, Israel, Microsoft
– Aren’t preceded by articles
– Capitalized )In English(
• Common Nouns:– Count Nouns:
• allow grammatical enumeration )book, books(
• can be counted )one apple, 50 thoughts(
– Mass Nouns: snow, salt, communism, …
89-6809
Verbs
מילים המתייחסות לפעולות או תהליכים•–Main verbs – draw, provide, differ–Auxiliaries )referred to as closed-class(
מערכת הטיה מורפולוגית•–eat, eats, eating, eaten
89-68010
Adjectives
מבחינה סמנטית, קבוצה הכוללת ביטויים •המתארים תכונות או איכויות, משהו כמו פרדיקט
חד-מקומי. :שפות רבות כוללות•
(yellow, greenצבעים )–(young, old גילאים )–(good, bad ) וערכים.–
יש שפות בלי שמות תואר.•
89-68011
Adverbs
קבוצה מעורבת למדי... •• Unfortunately, John walked home extremely slowly yesterday
• Directional: sideways, downhill
• Locative: home, here
• Degree: extremely, somewhat
• Manner: slowly, delicately
• Temporal: yesterday, Monday
89-68012
Closed class
• Prepositions – on, under, over, near, by, at, from, to, with
• Determiners – a, an, the• Pronouns – it, she I• Conjunctions – and, but, or, as, if, when• Auxiliary verbs – can, may, should, are• Particles – up, down, on, off, in , at, by• Numerals – one, two , second, third
89-68013
Prepositions and particles.
• Prepositions•on top, by then, with him... מילות יחס המופיעות לפני שם עצם•מצינות יחסי זמן/מקום, אבל לא רק. •
• Particles•go on, look up, turn down
מופיעים אחרי פועל, ובפעלים טרנזיטיביים, גם אחרי •המושא
–The horse went off its truck/throw off sleep–*The horse went its track off/throw sleep off
89-68014
Articles
•a, an, the
noun phraseמופיעים בתחילה צירוף שמני •
this chapter, that pageגם: •
שכיחים מאוד בטקסטים•
89-68015
Conjunctions
, צירופים , משפטים, וכו. phrasesמאחים שני •
•Or, and, but מאחים צירופים מאותו סטטוס
•Subordinating conjunctions משמשים לאיחוי צירופים מקוננים
• I thought that you might like some milk.– I thought – main clause– That you might… - subordinating clause
89-68016
ויש עוד...
89-68017
Tagsets
TagsetThe set of possible tags for parts of speech. )size is
changing in applications, languages...( A tagset should include the information that is needed
for the next steps in the process, and that people can annotate well
Brown corpus – 87 tagsPenn Treebank – 45Large: 146-tag C7 tagset of used to tag the British
National Corpus BNC.
89-68018
Part-Of-Speech Tagging
תיוג הוא התהליך של השמת חלקי דיבר או סימון •(tokenizationלקסיקלי אחר לכל מילה בקורפוס. )
תיוג מתבצע בדרך כלל גם על סימני פיסוק• מהסוג שראינו.tagsetהקלט הוא רצף מילים ו-•הפלט הוא התיוג הטוב ביותר עבור כל אחת מן המילים.•:ambiguityוהבעייה המרכזית, היא – •
–Time flies like an arrow/ fruit flies like
–I can can my can אישה נעלה נעלה נעלה נעלה את/הדלת...
89-68019
The Distribution of Tags
• Tags follow all the usual frequency-based distributional behavior.
• Most word types have only one part of speech. • Of the rest, most have two. Things go pretty much as we'd
expect from there on. • Of course, as usual, the most frequently occurring word types
tend to have multiple tags. • )As we'll see later in the semester, they also tend to have
more meanings(. • Therefore while its easy to determine the correct tag for most
word types, it isn't necessarily so easy to tag most texts.
89-68020
Word Types in the Brown CorpusUnambiguous )1 tag(35340
Ambiguous )2-7 tags(4100
2 tags3760
3 tags264
4 tags61
5 tags12
6 tags2
7 tags1“( still)”
89-68021
State of the Art
• A dumb tagger that simply assigns the most common tag to each word achieves ~90%
• Best approaches give ~96/97% • This still means that there will be on
average one tagging error per sentence• Life is much more difficult if we do not
have a lexicon and/or training corpus or if we use a tagger across domains and genres.
89-68022
מתייגים
- מבוססי חוקים•קידוד ידני––Transformation-based tagging )learning(
• Stochastic Taggingהסתברותיים - –HMM–Bayesian networks–Maximum entropy
89-68023
Supervised Learning Scheme
ClassificationModel
“Labeled”Examples
NewExamples Classifications
Training Algorithm
ClassificationAlgorithm
89-68024
איך זה עובד?
P)NN|race( = 0.98 P)VB|race(=0.02
בצעד הראשון, יתוייג המשפט לפי התג הסביר יותר:
is/VBZ expected/VBN to/TO race/NN tomorrow
the/DT race/NN for/IN outer/JJ space/NNאחרי הבחירה הראשונית של התג, המתייג מבצעה את •
הטרנפורמציות שלמד מהקורפוס – לדוגמא:•Change NN to VN when the previous tag is TOto/TO race/VB ב-race/NN to/TOהחוק הזה יחליף את •
89-68025
Transformational Based Learning )TBL( for Tagging
• Introduced by Brill )1995(• Can exploit a wider range of lexical and syntactic
regularities via transformation rules – triggering environment and rewrite rule
• Tagger:– Construct initial tag sequence for input – most frequent
tag for each word– Iteratively refine tag sequence by applying
“transformation rules” in rank order• Learner:
– Construct initial tag sequence for the training corpus– Loop until done:
• Try all possible rules and compare to known tags, apply the best rule r* to the sequence and add it to the rule ranking
89-68026
Some examples
1. Change NN to VB if previous is TO– to/TO conflict/NN with VB
2. Change VBP to VB if MD in previous three– might/MD vanish/VBP VB
3. Change NN to VB if MD in previous two– might/MD reply/NN VB
4. Change VB to NN if DT in previous two– the/DT reply/VB NN
89-68027
Transformation Templates
• Specify which transformations are possible
For example: change tag A to tag B when:1. The preceding )following( tag is Z
2. The tag two before )after( is Z
3. One of the two previous )following( tags is Z
4. One of the three previous )following( tags is Z
5. The preceding tag is Z and the following is W
6. The preceding )following( tag is Z and the tag two before )after( is W
89-68028
LexicalizationNew templates to include dependency on surrounding
words )not just tags(:Change tag A to tag B when:
1. The preceding )following( word is w2. The word two before )after( is w3. One of the two preceding )following( words is w4. The current word is w5. The current word is w and the preceding )following(
word is v6. The current word is w and the preceding )following( tag
is X )Notice: word-tag combination(7. etc…
89-68029
Initializing Unseen Words• How to choose most likely tag for unseen
words?Transformation based approach:
– Start with NP for capitalized words, NN for others
– Learn “morphological” transformations from:Change tag from X to Y if:
1. Deleting prefix )suffix( x results in a known word2. The first )last( characters of the word are x3. Adding x as a prefix )suffix( results in a known word4. Word W ever appears immediately before )after( the word5. Character Z appears in the word
89-68030
UnannotatedInput Text
AnnotatedText
Ground Truth forInput Text
RulesLearning Algorithm
TBL Learning Scheme
Setting InitialState
89-68031
Greedy Learning Algorithm
• Initial tagging of training corpus – most frequent tag per word
• At each iteration: – Identify rules that fix errors and compute
“error reduction” for each transformation rule:• #errors fixed - #errors introduced
– Find best rule; If error reduction greater than a threshold (to avoid overfitting):• Apply best rule to training corpus
• Append best rule to ordered list of transformations
89-68032
Next Week … HMMs
לא לשכוח שעורי בית...•
top related