SlideShare una empresa de Scribd logo
1 de 12
Tekstu analīze
LU specseminārs Web Science




                              Normunds Grūzītis
                                    15.11.2012.
Semantiskā analīze?
• Valodas vienību nozīmes (LLVV)
   – Vārda nozīme (paradigmatiskā analīze)
       • Lexical semantics

   – Teikuma nozīme (sintagmatiskā analīze)
       • Lexical semantics, Frame semantics, Computational semantics

   – Teksta nozīme (pragmatiskā analīze)
       • Computational semantics, Discourse semantics, Anaphora resolution

• Automātiska semantiskā analīze
   – Formalizēti leksiksko un “pasaules” zināšanu avoti
   – Sistemātiskas formālās (surface) pazīmes  likumi
       • manuāli / statistiski (data-driven)

   – Formālisms
Valodas saprašana un ģenerēšana
                                                     Secināšana

                                                       Modelis
       Interpretēšana




                                                                                                          Verbalizēšana
                                                  Teksta semantika
                                                 Teikuma semantika
                                                      Sintakse
                                                     Morfoloģija
                                                        Runa

                                                   Komunicēšana

Unrestricted English:                     Computer Processable English:           Boeing Language Understanding Engine:
An alien measures the height of a         • An alien drops a boulder.             isa(alien01,Foreigner),
cliff by dropping a boulder from          • The initial speed of the boulder is   isa(boulder01,Bowlder),
                                                                                  isa(drop01,Drop),
rest and measuring the time it              0 m/s.                                isa(speed01,Velocity),
takes to hit the ground below.            • The boulder drops for 23 seconds.     isa(distance01,Distance),
The boulder fell for 23 seconds on        • The acceleration of the boulder is    isa(height01,Height),
a planet with an acceleration of            7.9 m/s^2.                            isa(cliff01,Cliff),
                                                                                  agent(drop01,alien01),
gravity of 7.9m/s2.                       • The distance of the drop equals       object(drop01,boulder01),
Assuming constant acceleration              the height of the cliff.              value(speed01,[0,*m/s]),
and ignoring air resistance, how          • What is the height of the cliff?      speed(boulder01,speed01),
                                                                                  ...
high was the cliff?                                                               equal(distance01,height01),
                           patvaļīga / kontrolēta valoda                          distance(drop01,distance01),
                                                                                  height(cliff01,height01).
                           deterministiska / varbūtiska analīze
Daudznozīmība visos līmeņos
• Morfoloģiskā analīze
    – „es”: {pron,sg,pers1,”es”}
    – „ceļu”: {v,indic,pres,pers1,”celt”} VAI {n,sg,acc,”ceļš”} VAI {n,pl,gen,”ceļš”} VAI
       {n,pl,gen,”celis”}
    – „māju”: {n,sg,acc,”māja”} VAI {n,pl,gen,”māja”} VAI {v,indic,pres,pers1,”māt”}

• Sintaktiskā analīze
    – „es”SUBJEKTS + „celt”PREDIKĀTS + „māja”OBJEKTS
    – „es”SUBJEKTS + „ceļš”OBJEKTS + „māt”PREDIKĀTS
• Semantiskā analīze
    – leksiskā semantika: „māja” ir hiponīms „celtne”BUILDING, bet „celt” ir sinonīms „būvēt”BUILD
      VAI hiponīms “pārvietot”MOVE
    – verba tipiskie paplašinātāji:
          •   „māt”WAVE ir intransitīvs – parasti tiek lietots kopā ar netiešo objektu (piem., ar ko?), nevis tiešo objektu (ko?)
          •   „celt”BUILD un „celt”MOVE ir transitīvi – parasti tiek lietoti kopā ar tiešo objektu; netiešais objekts – neobligāts

    – fona zināšanas: Tas, ko kāds būvē, ir celtne. Ikviena celtne ir nekustamais īpašums. Tas,
      ko kāds pārvieto, ir kustamais īpašums. Kustamais īpašums nav nekustamais īpašums.
Zifa likums
Zipf’s law:
• salīdzinoši maz vārdu tiek lietoti bieži — lielākā daļa tiek lietoti reti
• dažādos kontekstos vārdi tiek intensīvi atkalizmantoti
 100
  90
  80
  70
  60
  50                                                    Ierobežots skaits vārdu
  40
  30
                                                        Neierobežots skaits jēdzienu (nozīmju)
  20
  10
   0
          "the"        100         3500         7500


Daudznozīmība: fenomenāls līdzeklis, kas               Parādās visos teksta analīzes līmeņos: no
valodas lietošanu padara ērtu cilvēkam.                morfoloģisko pazīmju līdz pat diskursa
                                                       referentu noteikšanai.
Vārdu, vārdformu un sintaktisko
konstrukciju klāsts valodā ir galīgs, taču to          Jo augstāks līmenis, jo nosacīti
kombinēšanas un interpretācijas iespējas               valodneatkarīgākas problēmas/risinājumi
teorētiski ir bezgalīgas.                              (bet ne resursi!).
Teksta klasificēšana – semantiska problēma?
•   Derīgo vēstuļu un mēstuļu šķirošana
•   Anonīma autora noteikšana (t.sk. plaģiātisma atklāšana)
•   Autora vecuma/dzimuma noteikšana
•   Emocionālās ekspresijas noteikšana (sentiment analysis)
•   Teksta tematikas noteikšana
• Dots dokuments d un fiksēta klašu kopa C={c1, .., cn} (n≥2)
     – Noteikt d atbilstošo cj

• Vai tam ir nepieciešama semantiskā analīze?
     – Vai tas izklausās pēc teksta nozīmes analīzes?

• Vienkāršoti risinājumi (balstīti uz atslēgvārdiem/frāzēm):
     – manuāli definēti likumi, heiristika (dārgi, lēni)
     – mašīnmācīšanās no piemēriem (nepieciešama treniņpiemēru kopa)
Mašīnmācīšanās
• Programmu ģenerēšana, balstoties uz reprezentatīviem
  piemēriem
• Problēmas, kurām nav zināmas precīzas metodes, kā tās
  risināt, vai arī zināmās metodes ir pārāk “dārgas”
• Programma mācās no pieredzes E attiecībā pret uzdevumu
  klasi T un precizitātes/veiktspējas mēru P, ja laika gaitā P
  uzlabojas ar jaunu pieredzi E
   – Veiktspējas uzlabošanu bieži var reducēt uz kādas mērķa funkcijas
     mācīšanos
   – Vispārīgā gadījumā varam cerēt iegūt tikai ideālās mērķa funkcijas
     aproksimāciju
Naive Bayes metode
• Viena no vienkāršākajām un efektīvākajām ML metodēm
   – Tekstu klasificēšanai
• Bayes likums:
   – P(c|d) = P(d|c)*P(c) / P(d)
       • Varbūtība, ka c, ja d
       • “/ P(d)” var atmest, jo tas nav atkarīgs no c (konstante)

• Vienkāršots (aplams!) pieņēmums:
   – bag of words: d = w1, w2, .., wn (pazīmju vektors)
   – conditional independence: P(wi|cj)  P(w1,..,wn|cj) = P(w1|cj)*..*P(wn|cj)
   – t.i., vārdi tekstā nav savstarpēji atkarīgi, secība nav svarīga
• Naive Bayes:
   – argmax P(cj) * Π P(wi|cj)
        cj   C         i   Pos
Sec.13.2.1


            Naïve Bayes as a Language Model
 • Which class assigns the higher probability to the sentence s?
   – P(s|c) = Π P(w|c)


 Model pos          Model neg     I           love     this       fun     film

0.1 I             0.2   I
                                  0.1         0.1      0.01       0.05    0.1
0.1 love          0.001 love      0.2         0.001    0.01       0.005   0.1

0.01 this         0.01 this
                                        P(s|pos) > P(s|neg)
0.05 fun          0.005 fun             0.0000005 > 0.000000001
0.1 film          0.1   film
Kā radās P(cj) un P(wi|cj) vērtības?


    ˆ ) = doccount(C = c j )
    P(c j
                                                klases cj relatīvais biežums
                                                treniņpiemēru kopā
               N doc



                                                cik bieži vārds wi ir lietots klases cj

    ˆ              count(wi , c j )             dokumentos / kopējais vārdu skaits
    P(wi | c j ) =                              cj dokumentos (treniņpiemēros)
                   å count(w, c j )             t.i., wi relatīvais biežums cj
                    wÎV                         dokumentos (treniņpiemēros)




P.S. NB klasifikatora apmācīšana savām vajadzībām bez programmēšanas: uClassify.com
Teksta normalizēšana
• Kodējumi, tokenizācija, speciālo simbolu un vārdu vispārināšana utt.
• Biežumsaraksti un to analīze
    – Stopvārdi, “troksnis” (Zipf’s Law)
    – Vārdformas vs. pamatformas (īpaši aktuāli fleksīvām valodām)
         • Treniņpiemēri un datu (pazīmju – features) izkliedētība (sparsity)

• Vārdlietojumu klasterēšana
    – Naivās metodes: truncation, stemming, regex
    – Morfoloģiskā analīze:
         • Vārdšķiras (u.c. morf. pazīmju) noteikšana
              – Atvērtās / slēgtās vārdšķiras

              – Pilnnozīmes / palīgnozīmes vārdi

         • Pamatformas noteikšana (“lemmatizācija”)

    – Locīšanas paradigmas (piem., lietvārdi: 6 vai 60?)
Morfoloģiskā analīze vs. marķēšana
• Dots: individuāla (ārpus konteksta) vārdforma vs. teikums
• Analizators vs. statistisks tageris (POS tagger)
     – Baseline: ~90%
     – State of the art: ~97%
• LU MII tageris: ~93%
     – Vārdšķiras noteikšana: 97%
     – Drīzumā gaidāma uzlabota versija
• LU MII analizators
     – Morf. leksikons (~50K sugasvārdu, ~180K īpašvārdu)
     – Nezināmo vārdu minēšana pēc galotnes
     – Atgriež visus variantus, sakārtojot pēc dotās formas biežuma morf. korpusā
       (precizitāte: ~88%)
•   https://github.com/PeterisP/LVTagger

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

LU specseminārs Web Science: Tekstu analīze

  • 1. Tekstu analīze LU specseminārs Web Science Normunds Grūzītis 15.11.2012.
  • 2. Semantiskā analīze? • Valodas vienību nozīmes (LLVV) – Vārda nozīme (paradigmatiskā analīze) • Lexical semantics – Teikuma nozīme (sintagmatiskā analīze) • Lexical semantics, Frame semantics, Computational semantics – Teksta nozīme (pragmatiskā analīze) • Computational semantics, Discourse semantics, Anaphora resolution • Automātiska semantiskā analīze – Formalizēti leksiksko un “pasaules” zināšanu avoti – Sistemātiskas formālās (surface) pazīmes  likumi • manuāli / statistiski (data-driven) – Formālisms
  • 3. Valodas saprašana un ģenerēšana Secināšana Modelis Interpretēšana Verbalizēšana Teksta semantika Teikuma semantika Sintakse Morfoloģija Runa Komunicēšana Unrestricted English: Computer Processable English: Boeing Language Understanding Engine: An alien measures the height of a • An alien drops a boulder. isa(alien01,Foreigner), cliff by dropping a boulder from • The initial speed of the boulder is isa(boulder01,Bowlder), isa(drop01,Drop), rest and measuring the time it 0 m/s. isa(speed01,Velocity), takes to hit the ground below. • The boulder drops for 23 seconds. isa(distance01,Distance), The boulder fell for 23 seconds on • The acceleration of the boulder is isa(height01,Height), a planet with an acceleration of 7.9 m/s^2. isa(cliff01,Cliff), agent(drop01,alien01), gravity of 7.9m/s2. • The distance of the drop equals object(drop01,boulder01), Assuming constant acceleration the height of the cliff. value(speed01,[0,*m/s]), and ignoring air resistance, how • What is the height of the cliff? speed(boulder01,speed01), ... high was the cliff? equal(distance01,height01), patvaļīga / kontrolēta valoda distance(drop01,distance01), height(cliff01,height01). deterministiska / varbūtiska analīze
  • 4. Daudznozīmība visos līmeņos • Morfoloģiskā analīze – „es”: {pron,sg,pers1,”es”} – „ceļu”: {v,indic,pres,pers1,”celt”} VAI {n,sg,acc,”ceļš”} VAI {n,pl,gen,”ceļš”} VAI {n,pl,gen,”celis”} – „māju”: {n,sg,acc,”māja”} VAI {n,pl,gen,”māja”} VAI {v,indic,pres,pers1,”māt”} • Sintaktiskā analīze – „es”SUBJEKTS + „celt”PREDIKĀTS + „māja”OBJEKTS – „es”SUBJEKTS + „ceļš”OBJEKTS + „māt”PREDIKĀTS • Semantiskā analīze – leksiskā semantika: „māja” ir hiponīms „celtne”BUILDING, bet „celt” ir sinonīms „būvēt”BUILD VAI hiponīms “pārvietot”MOVE – verba tipiskie paplašinātāji: • „māt”WAVE ir intransitīvs – parasti tiek lietots kopā ar netiešo objektu (piem., ar ko?), nevis tiešo objektu (ko?) • „celt”BUILD un „celt”MOVE ir transitīvi – parasti tiek lietoti kopā ar tiešo objektu; netiešais objekts – neobligāts – fona zināšanas: Tas, ko kāds būvē, ir celtne. Ikviena celtne ir nekustamais īpašums. Tas, ko kāds pārvieto, ir kustamais īpašums. Kustamais īpašums nav nekustamais īpašums.
  • 5. Zifa likums Zipf’s law: • salīdzinoši maz vārdu tiek lietoti bieži — lielākā daļa tiek lietoti reti • dažādos kontekstos vārdi tiek intensīvi atkalizmantoti 100 90 80 70 60 50 Ierobežots skaits vārdu 40 30 Neierobežots skaits jēdzienu (nozīmju) 20 10 0 "the" 100 3500 7500 Daudznozīmība: fenomenāls līdzeklis, kas Parādās visos teksta analīzes līmeņos: no valodas lietošanu padara ērtu cilvēkam. morfoloģisko pazīmju līdz pat diskursa referentu noteikšanai. Vārdu, vārdformu un sintaktisko konstrukciju klāsts valodā ir galīgs, taču to Jo augstāks līmenis, jo nosacīti kombinēšanas un interpretācijas iespējas valodneatkarīgākas problēmas/risinājumi teorētiski ir bezgalīgas. (bet ne resursi!).
  • 6. Teksta klasificēšana – semantiska problēma? • Derīgo vēstuļu un mēstuļu šķirošana • Anonīma autora noteikšana (t.sk. plaģiātisma atklāšana) • Autora vecuma/dzimuma noteikšana • Emocionālās ekspresijas noteikšana (sentiment analysis) • Teksta tematikas noteikšana • Dots dokuments d un fiksēta klašu kopa C={c1, .., cn} (n≥2) – Noteikt d atbilstošo cj • Vai tam ir nepieciešama semantiskā analīze? – Vai tas izklausās pēc teksta nozīmes analīzes? • Vienkāršoti risinājumi (balstīti uz atslēgvārdiem/frāzēm): – manuāli definēti likumi, heiristika (dārgi, lēni) – mašīnmācīšanās no piemēriem (nepieciešama treniņpiemēru kopa)
  • 7. Mašīnmācīšanās • Programmu ģenerēšana, balstoties uz reprezentatīviem piemēriem • Problēmas, kurām nav zināmas precīzas metodes, kā tās risināt, vai arī zināmās metodes ir pārāk “dārgas” • Programma mācās no pieredzes E attiecībā pret uzdevumu klasi T un precizitātes/veiktspējas mēru P, ja laika gaitā P uzlabojas ar jaunu pieredzi E – Veiktspējas uzlabošanu bieži var reducēt uz kādas mērķa funkcijas mācīšanos – Vispārīgā gadījumā varam cerēt iegūt tikai ideālās mērķa funkcijas aproksimāciju
  • 8. Naive Bayes metode • Viena no vienkāršākajām un efektīvākajām ML metodēm – Tekstu klasificēšanai • Bayes likums: – P(c|d) = P(d|c)*P(c) / P(d) • Varbūtība, ka c, ja d • “/ P(d)” var atmest, jo tas nav atkarīgs no c (konstante) • Vienkāršots (aplams!) pieņēmums: – bag of words: d = w1, w2, .., wn (pazīmju vektors) – conditional independence: P(wi|cj)  P(w1,..,wn|cj) = P(w1|cj)*..*P(wn|cj) – t.i., vārdi tekstā nav savstarpēji atkarīgi, secība nav svarīga • Naive Bayes: – argmax P(cj) * Π P(wi|cj) cj C i Pos
  • 9. Sec.13.2.1 Naïve Bayes as a Language Model • Which class assigns the higher probability to the sentence s? – P(s|c) = Π P(w|c) Model pos Model neg I love this fun film 0.1 I 0.2 I 0.1 0.1 0.01 0.05 0.1 0.1 love 0.001 love 0.2 0.001 0.01 0.005 0.1 0.01 this 0.01 this P(s|pos) > P(s|neg) 0.05 fun 0.005 fun 0.0000005 > 0.000000001 0.1 film 0.1 film
  • 10. Kā radās P(cj) un P(wi|cj) vērtības? ˆ ) = doccount(C = c j ) P(c j klases cj relatīvais biežums treniņpiemēru kopā N doc cik bieži vārds wi ir lietots klases cj ˆ count(wi , c j ) dokumentos / kopējais vārdu skaits P(wi | c j ) = cj dokumentos (treniņpiemēros) å count(w, c j ) t.i., wi relatīvais biežums cj wÎV dokumentos (treniņpiemēros) P.S. NB klasifikatora apmācīšana savām vajadzībām bez programmēšanas: uClassify.com
  • 11. Teksta normalizēšana • Kodējumi, tokenizācija, speciālo simbolu un vārdu vispārināšana utt. • Biežumsaraksti un to analīze – Stopvārdi, “troksnis” (Zipf’s Law) – Vārdformas vs. pamatformas (īpaši aktuāli fleksīvām valodām) • Treniņpiemēri un datu (pazīmju – features) izkliedētība (sparsity) • Vārdlietojumu klasterēšana – Naivās metodes: truncation, stemming, regex – Morfoloģiskā analīze: • Vārdšķiras (u.c. morf. pazīmju) noteikšana – Atvērtās / slēgtās vārdšķiras – Pilnnozīmes / palīgnozīmes vārdi • Pamatformas noteikšana (“lemmatizācija”) – Locīšanas paradigmas (piem., lietvārdi: 6 vai 60?)
  • 12. Morfoloģiskā analīze vs. marķēšana • Dots: individuāla (ārpus konteksta) vārdforma vs. teikums • Analizators vs. statistisks tageris (POS tagger) – Baseline: ~90% – State of the art: ~97% • LU MII tageris: ~93% – Vārdšķiras noteikšana: 97% – Drīzumā gaidāma uzlabota versija • LU MII analizators – Morf. leksikons (~50K sugasvārdu, ~180K īpašvārdu) – Nezināmo vārdu minēšana pēc galotnes – Atgriež visus variantus, sakārtojot pēc dotās formas biežuma morf. korpusā (precizitāte: ~88%) • https://github.com/PeterisP/LVTagger