Скачать презентацию עיבוד שפות טבעיות — שיעור רביעי Part Скачать презентацию עיבוד שפות טבעיות — שיעור רביעי Part

2b89cfa0dc1e7f4633019f45377193c6.ppt

  • Количество слайдов: 32

 עיבוד שפות טבעיות - שיעור רביעי Part of Speech Tagging עידו דגן המחלקה עיבוד שפות טבעיות - שיעור רביעי Part of Speech Tagging עידו דגן המחלקה למדעי המחשב אוניברסיטת בר אילן 086 -98 1

 חלקי-הדיבור • מקובל למנות 9~ קבוצות מילים המכונות חלקי-הדיבור • מקובל למנות 9~ קבוצות מילים המכונות "חלקי- דיבור": • שם עצם ) , (noun שם תואר ) , (adjective כינוי ) , (pronoun שם מספר ) , (numeral פועל ) , (verb תואר הפועל ) , (adverb מלת יחס ) , (preposition מלת חיבור ) , (conjunction מלת קריאה ). (interjection • אך זו רק חלוקה אחת 086 -98 2

? למה זה טוב parsing • בסיס לניתוח : ( – אופן הביטוי של ? למה זה טוב parsing • בסיס לניתוח : ( – אופן הביטוי של המילה TTS) • יצירת קול – רכבת/רכבת CONtent/con. TENT, OBJect/obj. ECT, DIScount/dis. COUNT – Chunking/partial parsing/identifing terms • N-gram models for speech • IR, MT • 3 89 -680

 איך מגדירים חלקי דיבר? • באופן מסורתי, ההגדרה של חלקי הדיבר מבוססת על איך מגדירים חלקי דיבר? • באופן מסורתי, ההגדרה של חלקי הדיבר מבוססת על תכונות מורפולוגיות של המילה או על המילים שמופיעות לידן בסמיכות . distributional properties • באופן עקרוני, יש למילים מאותו חלק דיבר דמיון סמנטי, כלומר, הן מתארות איברים מאותן קבוצות למשל – – – שמות עצם – nouns אנשים, מקומות, דברים – , thought, table sister שמות תואר – adjectives תכונות, כמויות big, lazy לואי פעולה – – adverbs מתארים אופן, מקום, זמן, איכות quickly פעלים – אירועים, התרחשויות או מצבי קיום – eat, is, write 4 ויש גם מילות יחס, מילות 086 -98ועוד. . . איחוי

 דוגמא The yinkish dripner blorked quastofically into the nindin with the pidibs. • דוגמא 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. 5 89 -680

 Open class vs. Closed class types • • – Closed class הקבוצה שחבריה Open class vs. Closed class types • • – Closed class הקבוצה שחבריה קבועים בדרך כלל, כמו מילות יחס. –Open class למשל, שמות עצם ופעלים: מילים חדשות מתווספות לקבוצה , to fax לפקסס בקורפוסים שונים ייצפו מילים שונות מהקבוצה הפתוחה, אבל אם הקורפוס גדול מספיק, סביר להניח שימצאו בהם אותם מילים השייכות לקבוצה הסגורה. מילים מהקבוצה הסגורה הן בדרך כלל function –words מילים השייכות לדקדוק כמו , of את – מילים קצרות בדרך כלל המופיעות בתדירות גבוהה, ולהן תפקיד תחבירי חשוב. 6 086 -98

 שמות עצם • Nouns – take -s, 's, -ness, -ment, -er, affixes – שמות עצם • 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 , • או שמות פעולה, למשל: אכילה, לאכול 7 89 -680

Types of Nouns • Proper Nouns: – David, Israel, Microsoft – Aren’t preceded by 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, … 8 89 -680

Verbs • מילים המתייחסות לפעולות או תהליכים Main verbs – draw, provide, differ – Verbs • מילים המתייחסות לפעולות או תהליכים Main verbs – draw, provide, differ – Auxiliaries (referred to as closed-class) – • מערכת הטיה מורפולוגית eat, eats, eating, eaten – 9 89 -680

 Adjectives • מבחינה סמנטית, קבוצה הכוללת ביטויים המתארים תכונות או איכויות, משהו כמו Adjectives • מבחינה סמנטית, קבוצה הכוללת ביטויים המתארים תכונות או איכויות, משהו כמו פרדיקט חד-מקומי. • שפות רבות כוללות: – צבעים ) (yellow, green – גילאים ) (young, old – וערכים. ) (good, bad • יש שפות בלי שמות תואר. 086 -98 01

Adverbs. . . • קבוצה מעורבת למדי • Unfortunately, John walked home extremely slowly Adverbs. . . • קבוצה מעורבת למדי • Unfortunately, John walked home extremely slowly yesterday • • • 11 Directional: sideways, downhill Locative: home, here Degree: extremely, somewhat Manner: slowly, delicately Temporal: yesterday, Monday 89 -680

Closed class • Prepositions – on, under, over, near, by, at, from, to, with 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, off, in , at, by • Numerals – one, two , second, third 12 89 -680

. Prepositions and particles • Prepositions on top, by then, with him. . . . Prepositions and particles • Prepositions on top, by then, with him. . . • • מילות יחס המופיעות לפני שם עצם . • מצינות יחסי זמן/מקום, אבל לא רק • Particles go on, look up, turn down • • מופיעים אחרי פועל, ובפעלים טרנזיטיביים, גם אחרי המושא 13 The horse went off its truck/throw off sleep – *The horse went 89 -680 its track off/throw sleep off –

Articles a, an, the noun phrase מופיעים בתחילה צירוף שמני this chapter, that page Articles a, an, the noun phrase מופיעים בתחילה צירוף שמני this chapter, that page : גם שכיחים מאוד בטקסטים 14 89 -680 • •

Conjunctions. , צירופים , משפטים, וכו phrases • מאחים שני מאחים צירופים מאותו סטטוס Conjunctions. , צירופים , משפטים, וכו phrases • מאחים שני מאחים צירופים מאותו סטטוס Or, and, but • משמשים לאיחוי Subordinating conjunctions • צירופים מקוננים • I thought that you might like some milk. – I thought – main clause – That you might… - subordinating clause 15 89 -680

 ויש עוד. . . 086 -98 61 ויש עוד. . . 086 -98 61

Tagsets Tagset The set of possible tags for parts of speech. (size is changing Tagsets Tagset The 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 tags Penn Treebank – 45 Large: 146 -tag C 7 tagset of used to tag the British National Corpus BNC. 17 89 -680

 Part-Of-Speech Tagging • • • תיוג הוא התהליך של השמת חלקי דיבר או Part-Of-Speech Tagging • • • תיוג הוא התהליך של השמת חלקי דיבר או סימון לקסיקלי אחר לכל מילה בקורפוס. ) (tokenization תיוג מתבצע בדרך כלל גם על סימני פיסוק הקלט הוא רצף מילים ו- tagset מהסוג שראינו. הפלט הוא התיוג הטוב ביותר עבור כל אחת מן המילים. והבעייה המרכזית, היא – : ambiguity – Time flies like an arrow/ fruit flies like – /I can my can אישה נעלה את הדלת. . . 086 -98 81

The Distribution of Tags • Tags follow all the usual frequency-based distributional behavior. • 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. 19 89 -680

Word Types in the Brown Corpus Unambiguous (1 tag) Ambiguous (2 -7 tags) 2 Word Types in the Brown Corpus Unambiguous (1 tag) Ambiguous (2 -7 tags) 2 tags 3 tags 4 tags 5 tags 6 tags 7 tags 20 35340 4100 3760 264 61 12 2 1 (“still”) 89 -680

State of the Art • A dumb tagger that simply assigns the most common 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. 21 89 -680

 מתייגים • - מבוססי חוקים – קידוד ידני Transformation-based tagging (learning) – - מתייגים • - מבוססי חוקים – קידוד ידני Transformation-based tagging (learning) – - הסתברותיים Stochastic Tagging • HMM – Bayesian networks – Maximum entropy – 22 89 -680

Supervised Learning Scheme “Labeled” Examples Training Algorithm Classification Model New Examples 23 Classification Algorithm Supervised Learning Scheme “Labeled” Examples Training Algorithm Classification Model New Examples 23 Classification Algorithm 89 -680 Classifications

? איך זה עובד P(NN|race) = 0. 98 P(VB|race)=0. 02 : בצעד הראשון, יתוייג ? איך זה עובד 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 TO • to/TO - ב to/TO race/NN • החוק הזה יחליף את race/VB 24 89 -680

Transformational Based Learning (TBL) for Tagging • Introduced by Brill (1995) • Can exploit 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 25 89 -680

Some examples 1. Change NN to VB if previous is TO – to/TO conflict/NN 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 26 89 -680

Transformation Templates • Specify which transformations are possible For example: change tag A to Transformation Templates • Specify which transformations are possible For example: change tag A to tag B when: 1. 2. 3. 4. 5. 6. 27 The preceding (following) tag is Z The tag two before (after) is Z One of the two previous (following) tags is Z One of the three previous (following) tags is Z The preceding tag is Z and the following is W The preceding (following) tag is Z and the tag two before (after) is W 89 -680

Lexicalization New templates to include dependency on surrounding words (not just tags): Change tag Lexicalization New templates to include dependency on surrounding words (not just tags): Change tag A to tag B when: 1. 2. 3. 4. 5. The preceding (following) word is w The word two before (after) is w One of the two preceding (following) words is w The current word is w and the preceding (following) word is v 6. The current word is w and the preceding (following) tag is X (Notice: word-tag combination) 7. etc… 28 89 -680

Initializing Unseen Words • How to choose most likely tag for unseen words? Transformation 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. 2. 3. 4. 5. 29 Deleting prefix (suffix) x results in a known word The first (last) characters of the word are x Adding x as a prefix (suffix) results in a known word W ever appears immediately before (after) the word Character Z appears in the word 89 -680

Unannotated Input Text TBL Learning Scheme Setting Initial State Ground Truth for Input Text Unannotated Input Text TBL Learning Scheme Setting Initial State Ground Truth for Input Text Annotated Text Learning Algorithm 30 89 -680 Rules

Greedy Learning Algorithm • Initial tagging of training corpus – most frequent tag per 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 31 89 -680

 Next Week … HMMs • לא לשכוח שעורי בית. . . 086 -98 Next Week … HMMs • לא לשכוח שעורי בית. . . 086 -98 23