1 / 45

עיבוד שפות טבעיות מבוא

עיבוד שפות טבעיות מבוא. פרופ' עידו דגן (קרדיט לחלק מהשקפים : אורן גליקמן) המחלקה למדעי המחשב אוניברסיטת בר אילן שינויים מאת אבי רוזנפלד. מה זה בכלל עיבוד שפות טבעיות. נקרא גם "בלשנות חישובית“ Natural Language Processing/ Computational Linguistics

emery
Télécharger la présentation

עיבוד שפות טבעיות מבוא

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. עיבוד שפות טבעיות מבוא פרופ' עידו דגן (קרדיט לחלק מהשקפים:אורן גליקמן) המחלקה למדעי המחשב אוניברסיטת בר אילן שינויים מאת אבי רוזנפלד

  2. מה זה בכלל עיבוד שפות טבעיות • נקרא גם "בלשנות חישובית“ • Natural Language Processing/Computational Linguistics • כל מה שקשור בהבנה, ניתוח, יצירה ועיבוד של שפות טבעיות (להבדיל משפות מחשב, למשל) • שפה מהווה ייצוג של משמעות – איננו מתיימרים להגיע להבנה "אמיתית" של משמעות, אלא לבצע פעולות מועילות למרות החוסר בהבנה, או להגיע למודלים מקורבים

  3. דוגמאות לאפליקציות/יישומים • תרגום ממוחשב • חיפוש ואחזור מידע • מענה לשאלות – Question Answering • שליפת מידע – Information Extraction • טיפול במונחים: שליפה, דמיון, סיווג שמות • תמצות אוטומטי • אפליקציות בתחום הדיבור: • מערכות דיאלוג • תיקון שגיאות כתיב ותחביר (eg. Microsoft Word) • ממשקים חדשים (קול, צ'ט)

  4. Towards text understanding: Question Answering

  5. Search may benefit understanding • Query: AIDS treatment • Irrelevant document: Hemophiliacs lack a protein, called factor VIII, that is essential for making blood clots. As a result, they frequently suffer internal bleeding and must receive infusions of clotting protein derived from human blood.During the early 1980s, these treatments were often tainted withthe AIDS virus. In 1984, after that was discovered, manufacturersbegan heating factor VIII to kill the virus. The strategy greatlyreduced the problem but was not foolproof. However, many expertsbelieve that adding detergents and other refinements to thepurification process has made natural factor VIII virtually free ofAIDS. (AP890118-0146, TIPSTER Vol. 1) • Many irrelevant documents mention AIDS and treatments for other diseases

  6. Relevant Document • Query: AIDS treatment Federal health officials are recommending aggressive use of a newly approved drug that protects people infected with the AIDS virus against a form of pneumonia that is the No.1 killer of AIDS victims.The Food and Drug Administration approved the drug, aerosol pentamidine, on Thursday. The announcement came as the Centers for Disease Control issued greatly expanded treatment guidelines recommending wider use of the drug in people infected with the AIDS virus but who may show no symptoms. (AP890616-0048, TIPSTER VOL. 1) • Relevant documents may mention specific types of treatments for AIDS

  7. מדעים קשורים • בלשנות • למידת מכונה והסקה סטטיסטית • פסיכולינגויסטיקה • מדעי המחשב (AI) • אלגוריתמים (חיפוש למשל) • מדעי המוח ((Cognitive Science

  8. שפה טבעית לעומת שפת מחשב • שפות מחשב (באופן כללי) הנן חד-משמעיות ומוגדרות היטב. קומפילר יכול (ע"י Parser) לתרגם קוד לפקודות שפת מכונה. לדוגמא: • יש הבחנה בין שווהבמשמעות של assignment (=) לעומת equality (==). • יש סדר מוגדר על פרדיקטים – • a גדול מ b ולא c או d • a > b && !c || d • a > b && (!c || d) • a > b && !(c || d)

  9. ו ו או • או (or) היינו דו משמעי בעברית (ואנגלית): • אתה יכול לקבל קפה או תה. (Exclusive) • אתה רוצה קפה או עוגה? (Inclusive) • עוד דוגמא: (טווח כמתים – quantifier scope) • "כמעט ניצחתי את כל שאר המתחרים בתחרות") • "באמת?" • "כן: כמעט ניצחתי את ירון, כמעט ניצחתי את איריס, כמעט ניצחתי את אלון,..."

  10. עברית קשה שפה • לא רק עברית ! • השפה הטבעית מלאת רב משמעויות, ברמות שונות: • כותרת תמונה בעיתון השבוע: • "גופות הרוגים בפיגוע ליד בית חולים בבאלי היום." • האם הפיגוע היה ליד בית חולים ? • מתי ארע הפיגוע?

  11. 242 • "Withdrawal of Israel armed forcesfrom territories occupied in the recent conflict" • עד היום מתווכים על הפרוש.

  12. רב משמעות תחבירית • במשפט הבא 15 מילים ולפחות 455(!) ניתוחים תחביריים אפשריים: List the sales of the products produced in 1973 with the products produced in 1972.

  13. Variability of Semantic Expression All major stock markets surged Dow gains 255 points Dow ends up Stock market hits a record high Dow climbs 255 The Dow Jones Industrial Average closed up 255

  14. AI & Turing Test • NLP נחשב כ-’AI complete’ • Turing Test: is a computer program intelligent? (1954)Would a human find out that he speaks with a computer?

  15. רמות ידע לשוני • פונטיקה ופונולוגיה • מורפולוגיה • תחביר (Syntax) • סמנטיקה • פרגמטיקה, שיח (Discourse) • ידע כללי (World Knowledge)

  16. הפרדה למילים ומשפטיםTokenization & Sentence splitting

  17. Tokenization • הבעיה הראשונית היא 'שבירת' הקלט למשפטים ולמילים. • במילים הכוונה גם למספרים וכד' • הגישה הנאיבית: • משפט מסתיים ב-'.','?','!‘ • מילה מופרדת ב- whitespace • אך המציאות:...

  18. Tokenization Issues • East Asian Languages • Some punctuation marks are part of words: .-” etc.

  19. Sentence breaks vs. words • '.','?','!' ולפעמים גם ':',';','-','\n' • ~ 90% of periods are sentence breaks • State of the art: 99% accuracy (learning methods) • English capitalization can help • The Problem: period . • can denote a decimal point (5.6), an abbreviation (Mr.), the end of a sentence, thousand segment separator: 3.200 (three-thousand-two-hundred, in Europe),initials: A. B. Smith, ellipsis …

  20. מה זה "מילה"? • ערך מילוני (למה): יחידת המידע העצמאית הקטנה ביותר בשפהלמשל: ספר, שולחןאבל לא: ה(ספר), (walk)-ed • מילה? She'd • בשפה כתובה, לא כל "מחרוזת" או "יחידה" המוקפת ברווחים היא למה - למשל:ואכלתיהו - ואני אכלתי אותו • מקובל להתייחס ליחידה הלקסיקאלית המינימאלית בטקסט כ-token

  21. מורפולוגיה • מילים מורכבות ממורפמות - morphemes שהן "יחידות המידע הקטנות ביותר הנושאות משמעות" • יש מילים הבנויות ממורפמה אחת: • car, fish • מילה יכולה להיות מורכבת מכמה מורפימות: • סוסיהם - סוס + י(ם) + הם • מעוניינים במודל למורפולוגיה של השפה • ניתוח • יצירה • חשיבות: איות, אחזור מידע, תנאי מקדים לניתוח תחבירי (ליישומים דקדוקיים וסמנטיים)

  22. מורפולוגיה – רב משמעות שם עצם נסמך הרכבת הא השאלה פועל ר.כ.ב בניין פעל עבר זכר יחיד שם עצם והא הידיעה פועל ר.כ.ב בניין הפעיל עבר נקבה יחיד פועל ר.כ.ב בניין הפעיל עבר זכר יחיד

  23. מנגנונים מורפולוגיים - מוספיות(affixes) : תחילית, תוכית, וסופית • מילים מחולקות ל-stem(אינו בהכרח מילה) ול-affixes • תחיליות - prefixes - הן המוספות בתחילת המילה • Un-believable, re-direction • סופיות - suffixes - מוספות בסוף המילהלמשל: ing :having, eating • תוכיות infixes - - מורפמה המוכנסת לגזע או שורש - למשל אותיות הקובעות בניין בעברית • התפעל - התרחץ, השתעל • Circumfix – שילוב של תחילית וסופית (למשל בגרמנית) • מבחינים בין מנגנון שרשורי (concatenative) למנגנון מבוסס תבניות (כגון שורש-בנין בשפות שמיות)

  24. הטיה inflection • שינוי שיכול לחול תמיד בצורת המילה מתוך צרכים תחביריים, שאינו משנה את הלמה (ואת חלק הדיבר).למשל : • מספר (יחיד/רבים) - number • נערה - נערות • מין gender • נער - נערה • גוףperson • אני רצתי - אנחנו רצנו • זמן tense • מערכת ההטיה תלויה בחלק הדיבר (ש"ע, פועל, שם תואר, ...) • בעברית מערכת ההטיות מורכבת

  25. הטיות באנגלית • באנגלית מערכת ההטיות פשוטה יחסית. מבוססת על מורפולוגיה משורשרת - concatenative morphology • עבור שמות עצם: ריבוי • יש חוקי כתיב orthographic rules למשל מלים שמסתיימות ב-x סימון לרבים יהיה -es ולא -s. • עבור פעלים: ההטיות מגוונות יותר:stem, 3rd person, -ing participle, past, past participle • בטורקית למשל – מערכת שרשורים ענפה (דוגמא עם 11 מרכיבים)

  26. Regulary Inflected verbs (by rules)

  27. מידול חישובילמורפולוגיה (הטיות)ניתוח ויצירה • Morphological analysis • ניתוח: קבלת קלט כלשהו ויצירת מבנה ממנו. • ניתוח מורפולוגי יקבל כקלט מילה כ-goingויחזיר כפלט את הניתוח • הלמה והמאפיינים המורפולוגיים של המילה VERB-GO + PARTICIPLE-ing

  28. דוגמאות • דוגמא פשוטה: ניתוח נטיות שמות עצם ופעלים • המטרה: קלט: catsפלט: cat + N + PL קלט: geese פלט: goose + N+ PL קלט: merging פלט: merge + V + PRES-PART קלט: caught פלט: catch + V + PAST-PART

  29. מטרות מודל מורפולוגי • ניתוח: • Recognizer: האם מילה היא תקנית או לא • Stemmer: מזהה את צורתהבסיס (stem) של מילה • Analyzer: נותן ניתוח מורפולוגי למלים • Generator: מייצר מילים מניתוח מורפולוגי מסוים

  30. Porter Stemmer • Example Rules: • Step 1a • SSES -> SS (passes  pass) • IES -> I (ponies  poni, ties  ti) • SS -> SS (caress  caress) • S  (cats  cat) • Step 1b (m – counts “syllables”) • (m>0) EED  EE (feed  feed, agreed  agree) • (*v*) ED  (plastered  plaster, bled  bled) (*v*) ING   (motoring  motor, sing  sing)

  31. Porter Algorithm • Step 2 • (m>0) ATIONAL -> ATE relational -> relate • (m>0) TIONAL -> TION conditional -> condition • (m>0) ENCI -> ENCE valenci -> valence • (m>0) ANCI -> ANCE hesitanci -> hesitance • (m>0) IZER -> IZE digitizer -> digitize • (m>0) ABLI -> ABLE conformabli -> conformable (m>0) ALLI -> AL radicalli -> radical • (m>0) ENTLI -> ENT differentli -> different • Etc…

  32. חלקי-הדיבר • ניתן למנות קבוצות מילים המכונות "חלקי- דיבור": • שם עצם (noun),שם תואר (adjective),כינוי (pronoun),שם מספר (numeral),פועל (verb),תואר הפועל (adverb),מלת יחס (preposition),מלת חיבור (conjunction), ... • זו רק חלוקה אחת (הקטגוריות העיקריות סטנדרטיות)

  33. דוגמא The yinkish dripner blorked quastofically into the nindin with the pidibs. • yinkish -adj quastofically -adverb • dripner -noun pidibs -noun • blorked -verb nindin -noun • 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.

  34. שמות עצם • Nouns • Affixes: -s, 's, -ness, -ment, -er, … • Occur with determiners (a,the,this,some…) • can be a subject of a sentence. • Semantically: can be concrete –chair, train, or abstract –relationship. • גם שמות פעולה, למשל: אכילה, לאכול, eating

  35. Types of Nouns • Important to distinguish noun types – have different morphological and syntactic properties • 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, … (no plural)

  36. Verbs • מילים המתייחסות לפעולות או תהליכים • Main verbs – draw, provide, differ • Auxiliaries (closed-class) – have (also main), been, … • מערכת הטיה מורפולוגית של פעלים: זמן, גוף, מין (לא באנגלית), מספר • eat, eats, eating, eaten

  37. Adjectives • מתאר משהו בשם עצם • שפות רבות כוללות: • צבעים (yellow, green) • גילאים (young, old) • וערכים. (good, bad)

  38. Adverbs • מתאר משהו על פועל • Unfortunately, John walked home extremely slowly yesterday • Directional: sideways, downhill • Locative: home, here • Degree: extremely, somewhat • Manner: slowly, delicately • Temporal: yesterday, Monday

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

  40. State of the Art • A dumb English 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 • Tagging 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.

  41. מתייגים • - מבוססי חוקים • קידוד ידני של חוקים • מערכת לבדיקת התאמת חוקים - בדר"כ מבוסס ביטויים רגולריים, והפעלה שלהם • Transformation-based tagging (learning) • Stochastic Tagging - הסתברותיים • HMM • Maximum entropy • Classifier based (e.g. SVM)

  42. Supervised Learning Scheme “Labeled” Examples Training Algorithm Classification Model New Examples Classification Algorithm Classifications

More Related