Woorden standaardiseren in tekstvoorverwerking voor begrip van natuurlijke taal
Gepubliceerd in · 7 min gelezen · 19 februari 2022
--
Stemming en Lemmatisering zijn algoritmen die worden gebruikt in Natural Language Processing (NLP) om tekst te normaliseren en woorden en documenten voor te bereiden voor verdere verwerking inMachinaal leren. In NLP, bijvoorbeeld, wil je misschien erkennen dat de woorden "vind ik leuk" en "vind ik leuk" hetzelfde woord zijn in verschillende tijden. Het doel is dan om beide woorden terug te brengen tot een gemeenschappelijke woordwortel, wat wordt gedaan door middel van Stemming of Lemmatisering. Op die manier worden beide woorden op dezelfde manier behandeld, anders zouden "like" en "liked" voor het model net zo verschillend zijn als "like" en "car".
Natuurlijke taalverwerkingis een tak van informatica die zich bezighoudt met het begrijpen en verwerken van natuurlijke taal, b.v. teksten of spraakopnamen. Het doel is dat een machine met mensen kan communiceren op dezelfde manier waarop mensen al eeuwenlang met elkaar communiceren.
Ook voor ons mensen is het leren van een nieuwe taal niet eenvoudig en vergt veel tijd en doorzettingsvermogen. Wanneer een machine een natuurlijke taal wil leren, is dat niet anders. Daarom zijn er binnen enkele deelgebieden ontstaanNatuurlijke taalverwerkingdie nodig zijn om de taal volledig te begrijpen.
Deze onderverdelingen kunnen ook onafhankelijk worden gebruikt om individuele taken op te lossen:
- Spraakherkenningprobeert opgenomen spraak te begrijpen en om te zetten in tekstuele informatie. Dit maakt het gemakkelijker voor stroomafwaartse algoritmen om het te verwerken. Spraakherkenning kan echter ook op zichzelf worden gebruikt om bijvoorbeeld dictaten of lezingen om te zetten in tekst.
- Onderdeel van spraaklabelswordt gebruikt om de grammaticale samenstelling van een zin te herkennen en om de afzonderlijke zinscomponenten, zoals een zelfstandig naamwoord of een werkwoord, te markeren.
- Erkenning van benoemde entiteitenprobeert binnen een tekst woorden en zinsdelen te vinden die kunnen worden toegewezen aan een vooraf gedefinieerde klasse. Zo kunnen bijvoorbeeld alle zinnen in een tekstgedeelte die de naam van een persoon bevatten of een tijd uitdrukken, worden gemarkeerd.
- Sentiment analyseclassificeert het sentiment van een tekst in verschillende niveaus. Hierdoor is het bijvoorbeeld mogelijk om automatisch te detecteren of een productreview positiever of negatiever is.
- Generatie van natuurlijke taalis een algemene groep applicaties die worden gebruikt om automatisch nieuwe teksten te genereren die zo natuurlijk mogelijk klinken. Zo kunnen korte productteksten worden gebruikt om volledige marketingbeschrijvingen van dit product te maken.
Stemmen en lemmatisering helpen op veel van deze gebieden door de basis te leggen voor het correct begrijpen van woorden en hun betekenis.
We gebruiken Stemming om achtervoegsels uit woorden te verwijderen en eindigen met een zogenaamde woordstam. De woorden "vind-ik-leuks", "waarschijnlijk" en "leuk gevonden" resulteren bijvoorbeeld allemaal in hun gemeenschappelijke woordstam "zoals" die kan worden gebruikt als synoniem voor alle drie de woorden. Op die manier kan een NLP-model leren dat alle drie de woorden op de een of andere manier vergelijkbaar zijn en in een vergelijkbare context worden gebruikt.
Stemmen stelt ons in staat woorden te standaardiseren naar hun basisstam, ongeacht hun verbuigingen, wat veel toepassingen helpt, zoals clusteren ofclassificerende tekst. Zoekmachines maken veelvuldig gebruik van deze technieken om betere resultaten te geven, ongeacht de woordvorm. Vóór de implementatie van woordstammen op Google in 2003 omvatte een zoekopdracht naar 'vis' geen websites over vissen of vissen.
Porters stemmenAlgoritme is een van de meest populaire Stemming-methoden en werd voorgesteld in 1980. Het is gebaseerd op het idee dat de achtervoegsels in de Engelse taal zijn samengesteld uit een combinatie van kleinere en eenvoudigere achtervoegsels. Het staat bekend om zijn efficiënte en eenvoudige processen, maar heeft ook verschillende nadelen.
Omdat het is gebaseerd op vele, hardgecodeerde regels die voortkomen uit de Engelse taal, kan het alleen worden gebruikt voor Engelse woorden. Er kunnen ook gevallen zijn waarin de uitvoer van Porter's Stemmer geen Engels woord is, maar alleen een kunstmatige woordstam.
van nltk.stem.porter importeren *
porter_voice = Portierstem()print(porter_votes.vote('alumnus'))Uit: 'alumnu'
De grootste problemen zijn echter Over- en Understemming, wat veelvoorkomende tekortkomingen zijn van de meeste van deze algoritmen.
Telkens wanneer ons algoritme meerdere woorden naar dezelfde wortel laat stammen, ook al zijn ze niet gerelateerd, noemen we dat over-stammen. Ook al zijn de woorden 'universeel', 'universiteit' en 'universum' verwant en komen ze uit hetzelfde stamwoord, toch liggen hun betekenissen ver uit elkaar. Wanneer we deze woorden in een goede zoekmachine zouden typen, zouden de zoekresultaten heel anders moeten zijn en niet als synoniemen moeten worden behandeld. We noemen zo'n fout een fout-positief.
Under-Stemming is precies het tegenovergestelde van dat gedrag en omvat gevallen waarin meerdere woorden niet voortkomen uit een gemeenschappelijke wortel, ook al zou dat wel moeten. Het woord "alumnus" beschrijft een voormalige student van een universiteit en wordt meestal gebruikt voor mannelijke personen. "Alumnae" is de vrouwelijke versie ervan en "alumni" zijn meerdere oud-studenten van een universiteit.
Deze woorden moeten absoluut als synoniemen worden behandeld in een basiszoekmachine of andere NLP-toepassingen. De meeste Stemming-algoritmen knippen het echter niet naar hun gemeenschappelijke root, wat een fout-negatieve fout is.
Lemmatisering is een ontwikkeling van Stemming en beschrijft het proces van het groeperen van de verschillende verbogen vormen van een woord, zodat ze als één item kunnen worden geanalyseerd. Lemmatisering is vergelijkbaar met Stemmen, maar het voegt context toe aan de woorden. Het koppelt dus woorden met vergelijkbare betekenissen aan één woord. Lemmatiseringsalgoritmen gebruiken meestal ook positionele argumenten als invoer, bijvoorbeeld of het woord een bijvoeglijk naamwoord, zelfstandig naamwoord of werkwoord is.
Telkens wanneer we tekstvoorverwerking voor NLP uitvoeren, hebben we zowel stemvorming als lemmatisering nodig. Soms vind je zelfs artikelen of discussies waarin beide woorden als synoniemen worden gebruikt, ook al zijn ze dat niet. Gewoonlijk heeft Lemmatisering de voorkeur boven Stemming omdat het een contextuele analyse van woorden is in plaats van een hardgecodeerde regel te gebruiken om achtervoegsels af te hakken. Als de tekstdocumenten echter erg lang zijn, kost het lemmatiseren aanzienlijk meer tijd, wat een ernstig nadeel is.
Kort gezegd is het verschil tussen deze algoritmen dat alleen een lemmatizer de betekenis van het woord meeneemt in de evaluatie. Bij het stammen wordt slechts een bepaald aantal letters aan het einde van het woord afgesneden om een woordstam te verkrijgen. De betekenis van het woord speelt daarin geen rol.
Zoals te zien is in het vorige voorbeeld, herkent een lemmatizer dat het Engelse woord "beter" is afgeleid van het woord "goed" omdat beide vergelijkbare betekenissen hebben. Stammen daarentegen kon zo'n onderscheid niet maken en zou waarschijnlijk "bet" of "bett" als stamwoord teruggeven.
Bij tekstvoorverwerking voor NLP hebben we zowel stam- als lemmatizers nodig, dus beide algoritmen hebben hun bestaansreden. Soms kun je zelfs artikelen of discussies vinden waarin beide woorden als synoniemen worden gebruikt, hoewel dat niet het geval is.
Doorgaans hebben lemmatizers de voorkeur boven stemmermethoden omdat het een contextuele analyse van woorden is in plaats van een hardgecodeerde regel te gebruiken om achtervoegsels af te kappen. Deze contextualiteit is vooral belangrijk wanneer content specifiek moet worden begrepen, zoals bijvoorbeeld bij een chatbot.
Voor andere toepassingen kunnen de functionaliteiten van Stemming voldoende zijn. Zoekmachines maken er bijvoorbeeld op grote schaal gebruik van om zoekresultaten te verbeteren. Door niet alleen op de zoekterm maar ook op de woordstammen in de index te zoeken, kunnen verschillende woordvormen worden overwonnen en kan het zoeken ook nog eens enorm worden versneld.
Zoals eerder vermeld, zijn deze twee methoden vooral interessant op het gebied vanNatuurlijke taalverwerking. De volgende toepassingen maken er gebruik van:
- Zoek algoritmen: De kwaliteit van zoekresultaten kan aanzienlijk worden verbeterd als bijvoorbeeld woordstammen worden gebruikt en spelfouten of meervoudsvormen dus niet zo belangrijk zijn.
- Kennis grafieken: Bij het bouwen van kennisstructuren, zoals een Knowledge Graph, helpen deze algoritmen om entiteiten, zoals mensen of plaatsen, te extraheren en te verbinden met andere entiteiten. Deze kennisgrafieken kunnen op hun beurt ook zoekalgoritmen verbeteren.
- Sentiment analyse: In veel toepassingen is het zinvol om teksten te classificeren op gevoel, bijvoorbeeld positief of negatief. Hierdoor kunnen bijvoorbeeld productreviews zeer snel worden geclassificeerd en gerichter worden verwerkt. Het gebruik van de gepresenteerde algoritmen kan het classificatiemodel helpen om betere voorspellingen te doen.
- Stemmen en lemmatiseren zijn methoden die ons helpen bij het voorbewerken van tekst voor natuurlijke taalverwerking.
- Beiden helpen om meerdere woorden toe te wijzen aan een gemeenschappelijk stamwoord.
- Op die manier worden deze woorden op dezelfde manier behandeld en leert het model dat ze in vergelijkbare contexten kunnen worden gebruikt.
Als je mijn werk leuk vindt, schrijf je dan inhierof kijk op mijn websiteData Basecamp! Met medium kun je ook lezen3 artikelenper maand gratis. Als je wilt hebbenonbeperkttoegang tot mijn artikelen en duizenden geweldige artikelen, aarzel niet om een lidmaatschap te krijgen voor $5per maand door op mijn verwijzingslink te klikken:https://medium.com/@niklas_lang/membership
FAQs
Which is more accurate stemming or lemmatization? ›
Lemmatization has higher accuracy than stemming. Lemmatization is preferred for context analysis, whereas stemming is recommended when the context is not important.
Should you do both stemming and lemmatization? ›Short answer- go with stemming when the vocab space is small and the documents are large. Conversely, go with word embeddings when the vocab space is large but the documents are small. However, don't use lemmatization as the increased performance to increased cost ratio is quite low.
Does lemmatization improve accuracy? ›As with any preprocessing technique, fine-tuning a lemmatization model has its pros and cons. One of the biggest advantages of fine-tuning a lemmatization model is that it can improve the accuracy and performance of the lemmatizer for your specific use case.
Should I do stemming and lemmatization in Python? ›The difference between stemming and lemmatization is that stemming is faster as it cuts words without knowing the context, while lemmatization is slower as it knows the context of words before processing.
Why is lemmatization a more effective option compared to stemming? ›In stemming, for some words, it may not give may not give meaningful representation such as “Histori”. Here, lemmatization comes into picture as it gives meaningful word. Lemmatization takes more time as compared to stemming because it finds meaningful word/ representation.
When might you use Lemmatizing over stemming? ›Stemming and Lemmatization both generate the foundation sort of the inflected words and therefore the only difference is that stem may not be an actual word whereas, lemma is an actual language word. Stemming follows an algorithm with steps to perform on the words which makes it faster.
What are the disadvantages of stemming? ›Disadvantages of stemming
Overstemming and understemming are two problems that can arise in stemming. Overstemming occurs when a stemmer reduces a word to its base form too aggressively, resulting in a stem that is not a valid word. For example, the word “fishing” might be overstemmed to “fishin,” which is not correct.
Stemming is faster because it chops words without knowing the context of the word in given sentences. Lemmatization is slower as compared to stemming but it knows the context of the word before proceeding. It is a rule-based approach. It is a dictionary-based approach.
What are the disadvantages of lemmatization? ›Disadvantages of Lemmatization
Time-consuming: Compared to stemming, lemmatization is a slow and time-consuming process. This is because lemmatization involves performing morphological analysis and deriving the meaning of words from a dictionary.
In general, lemmatization offers better precision than stemming, but at the expense of recall. Canonicalization. As we've seen, stemming andlemmatization are effective techniques to expand recall, withlemmatization giving up some of that recall to increase precision.
Does Google use stemming or lemmatization? ›
Words are traced back to a common word stem. Search engines such as Google use stemming algorithms to better evaluate search queries. Stemming is related to the lemmatization, where words are reduced to their basic or dictionary format.
Is lemmatization necessary in NLP? ›Lemmatization is an important part of natural language understanding and NLP, and also plays an important role in big data analytics and AI. For example, in big data analytics, lemmatization is used to normalize text documents.
Is stemming useful in NLP? ›The benefits of using the stemming algorithm in an NLP project can be summarised as follows: It reduces the number of words that serve as an input to the Machine Learning/Deep Learning model. It minimizes the confusion around words that have similar meanings. It lowers the complexity of the input space.
Is stemming necessary? ›Stemming is important in natural language understanding (NLU) and natural language processing (NLP). Stemming is a part of linguistic studies in morphology as well as artificial intelligence (AI) information retrieval and extraction.
Can stemming create invalid words? ›Due to its aggressiveness, there is a possibility that the outcome from the stemming algorithm may not be a valid word.
Should I remove stop words before lemmatization? ›Lemmatization and stop word removal are both potentially useful steps in preprocessing text, but they are not necessarily necessary. In order to determine whether either or both such steps should be taken, it is important to consider the nature of the problem.
What is the difference between lemmatization and stemming paper? ›The distinction between stemming and lemmatization is while stemming changes a word into a root word without knowing the context of the word like cutting off the ends of words, lemmatization changes a word into a root word by knowing the context of the word (Balakrishnan & Ethel, 2014) .
What is chunking in NLP? ›Chunking is defined as the process of natural language processing used to identify parts of speech and short phrases present in a given sentence.
What is the advantage and disadvantage of stemming? ›Pros and Cons
In general, the advantages of stemming are that it's straightforward to implement and fast to run. The trade-off here is that the output might contain inaccuracies, although they may be irrelevant for some tasks, like text indexing.
Lemmatization is extremely important because it is far more accurate than stemming. This brings great value when working with a chatbot where it is crucial to understand the meaning of a user's messages. The major disadvantage to lemmatization algorithms, however, is that they are much slower than stemming algorithms.
Does stemming remove stop words? ›
A. Stopword removal and stemming are two preprocessing techniques used in NLP to improve analysis. It removes non-meaningful words while stemming reduces words to their root form to reduce dimensionality and group similar words.
What are the errors in stemming? ›There are two error measurements in stemming algorithms, overstemming and understemming. Overstemming is an error where two separate inflected words are stemmed to the same root, but should not have been—a false positive.
Does stemming improve performance? ›Many researchersdemonstrate that stemming improves the performance of information retrieval systems. Porter stemmer isthe most common algorithm for English stemming.
Does stemming improve recall? ›Stemmers are used to conflate terms to improve retrieval effectiveness and /or to reduce the size of indexing file. Stemming will increase recall at the cost of decreased precision. Stemming can have marked effect on the size of indexing files ,sometimes decreasing the size of file as much as 50 percent .
What are the challenges from lemmatization? ›Main difficulties in Lemmatization arise from encountering previously unseen words during inference time as well as disambiguating ambiguous surface forms which can be inflected variants of several different base forms depending on the context.
What is one reason why stemming and lemmatization is used is to reduce the vocabulary size? ›Stemming and Lemmatization is the method to normalize the text documents. The main goal of the text normalization is to keep the vocabulary small, which help to improve the accuracy of many language modelling tasks. For example, vocabulary size will be reduced if we transform each word to lowercase.
Is lemmatization helps in morphological analysis of words True or false? ›Lemmatization usually refers to doing things properly with the use of a vocabulary and morphological analysis of words, normally aiming to remove inflectional endings only and to return the base or dictionary form of a word, which is known as the lemma .
What are the disadvantages of bag of words in NLP? ›Advantages | Disadvantages |
---|---|
Captures the essence of the document by representing it as a set of its constituent words. | The BoW approach can result in a high-dimensional feature space. As a result, finding significant patterns in the data may be challenging, due to the curse of dimensionality. |
Lemmatization technique is like stemming. The output we will get after lemmatization is called 'lemma', which is a root word rather than root stem, the output of stemming. After lemmatization, we will be getting a valid word that means the same thing.
What is the difference between stemming and lemmatization for tweets? ›The difference between stemming and lemmatization is, lemmatization considers the context and converts the word to its meaningful base form, whereas stemming just removes the last few characters, often leading to incorrect meanings and spelling errors.
Which is the most popular stemming algorithm? ›
Porter's Stemmer algorithm
It is one of the most popular stemming methods proposed in 1980. It is based on the idea that the suffixes in the English language are made up of a combination of smaller and simpler suffixes.
- Porter Stemmer.
- Snowball Stemmer.
- Lancaster Stemmer.
Stemming and Lemmatization are methods that help us in text preprocessing for Natural Language Processing. Both of them help to map multiple words to a common root word. That way, these words are treated similarly and the model learns that they can be used in similar contexts.
Does Word2Vec require lemmatization? ›Essentially by lemmatization, you make the input space sparser, which can help if you don't have enough training data. But since Word2Vec is fairly big, if you have big enough training data, lemmatization shouldn't gain you much.
What is the main challenge of NLP? ›The main challenge is information overload, which poses a big problem to access a specific, important piece of information from vast datasets. Semantic and context understanding is essential as well as challenging for summarisation systems due to quality and usability issues.
Why do I have to remove stop words in NLP? ›- They provide no meaningful information, especially if we are building a text classification model. Therefore, we have to remove stopwords from our dataset.
- As the frequency of stop words are too high, removing them from the corpus results in much smaller data in terms of size.
In general, lemmatization offers better precision than stemming, but at the expense of recall. Canonicalization. As we've seen, stemming andlemmatization are effective techniques to expand recall, withlemmatization giving up some of that recall to increase precision.
Does stemming increase precision? ›Stemming (and/or manual truncation) can give better precision (4-40 percent) in information retrieval for short queries (7-9 words) on short documents (500 words) than no stemming at all for languages as English, Dutch and Slovenian.
Does stemming lower precision? ›In a Boolean retrieval system, stemming never lowers precision. In a Boolean retrieval system, stemming never lowers recall. Stemming increases the size of the vocabulary. Stemming should be invoked at indexing time but not while processing a query.
What is the disadvantage of lemmatization? ›Lemmatization is extremely important because it is far more accurate than stemming. This brings great value when working with a chatbot where it is crucial to understand the meaning of a user's messages. The major disadvantage to lemmatization algorithms, however, is that they are much slower than stemming algorithms.
How does stemming affect precision? ›
Stemmers are used to conflate terms to improve retrieval effectiveness and /or to reduce the size of indexing file. Stemming will increase recall at the cost of decreased precision. Stemming can have marked effect on the size of indexing files ,sometimes decreasing the size of file as much as 50 percent .
Is accuracy increased by stemming explain it with the help of examples? ›For example, the stem of the words “eating,” “eats,” “eaten” is “eat.” Search engines use stemming for indexing the words. That's why rather than storing all forms of a word, a search engine can store only the stems. In this way, stemming reduces the size of the index and increases retrieval accuracy.
Why should we use stemming? ›Stemming is the process of reducing a word to its stem that affixes to suffixes and prefixes or to the roots of words known as "lemmas". Stemming is important in natural language understanding (NLU) and natural language processing (NLP).
Does increasing threshold increase precision? ›Raising the classification threshold typically increases precision; however, precision is not guaranteed to increase monotonically as we raise the threshold. Probably increase. In general, raising the classification threshold reduces false positives, thus raising precision.
What is the advantages and disadvantages of stemming? ›Pros and Cons
In general, the advantages of stemming are that it's straightforward to implement and fast to run. The trade-off here is that the output might contain inaccuracies, although they may be irrelevant for some tasks, like text indexing.