What is Stemming and how Does it Help Maximize Search Engine Performance?

IBM Technology
27 May 202415:58

Summary

TLDRこのビデオスクリプトでは、言語処理技術におけるstemming(語幹抽出)について解説しています。stemmingは、自然言語処理(NLP)のテキスト前処理技術の一つで、単語の異なる形態を基準形に減らして検索エンジンや情報検索の効率を高めるために使用されます。stemmingはルールに基づく手法で、単語の末尾を切り取ることで基準形を推測しますが、正確性に欠ける場合もあります。その一方で、lemmatizationはより正確な基準形を得るための技術で、単語の文脈を考慮します。stemmingはシンプルで実装が容易ですが、lemmatizationは計算コストが高く正確性が高いと特徴づけられています。stemmingの利点と限界、またPorter StemmerやSnowball Stemmerなどの具体的なアルゴリズムの動作についても紹介されています。

Takeaways

  • 🌿 ステミングは、自然言語処理(NLP)におけるテキスト前処理技術の一つです。
  • 🔍 ステミングは、単語をその基本形(stem)に還元するプロセスであり、「connect」という語幹から派生した様々な形態素を「connect」に戻すことが可能です。
  • 💡 ステミングは検索エンジンや情報検索において有用で、関連する様々な単語の形態素を網羅して検索結果をより正確にします。
  • 📚 ステミングは単語の語幹を見つけるためのヒューリスティックアルゴリズムであり、ルールに基づいて単語の末尾をトリミングします。
  • 📈 ステミングは次元削減にも役立ち、文書中のユニークな単語数を削減して機械学習モデルの特徴の数を減らします。
  • 📖 語彙の正規形を求めるlemmatizationと異なり、ステミングは単語の形態素を単純化するだけで、より簡単に実装できますが、精度は犠牲になります。
  • 🤖 Porter Stemmerは最も広く使われているステミングアルゴリズムの一つで、単語の母音と子音の組み合わせに基づいて単語をトリミングします。
  • 🌐 Snowball StemmerはPorter Stemmerを改良し、英語以外の言語にも対応した多言語対応のステミングアルゴリズムです。
  • 🚫 ステミングにはオーバーステミングとアンダーステミングという限界があり、時には単語の意味を失うことがあります。
  • 📚 ステミングは固有名詞の認識や同音異義語の扱いにおいて問題を引き起こすことがあり、言語によっては適切に機能しない場合もあります。

Q & A

  • 植物と言葉には何が共通していますか?

    -植物と言葉には両方とも「幹」を持っていることが共通しています。植物の場合、幹は葉、花、果実につながる中心的な部分です。言葉の場合、語幹は様々な形態変化を通じて関連する単語を結びつけます。

  • stemmingとはどのようなプロセスですか?

    -stemmingは自然言語処理におけるテキスト前処理技術です。異なる単語をその基本形、つまり語幹に戻すことを目的としたプロセスです。例えば、「connect」という語幹から「connected」、「connection」、「connects」などの単語を派生させることができます。

  • stemmingはどのようにして検索エンジンの検索結果に影響を与えますか?

    -stemmingは検索エンジンで関連する単語の様々な形態を網羅し、検索クエリとそれに関連する単語を含むドキュメントを関連付けるプロセスを可能にします。これにより、検索結果の関連性と精度が向上します。

  • stemmingとlemmatizationの違いは何ですか?

    -stemmingは単語の語尾を単純にカットして語幹に戻そうとする一方で、lemmatizationは単語の辞書にある正規化された形、つまり既存の単語形を取得するように試みます。lemmatizationはよりコンテキストを必要とし、より正確ですが、stemmingは単純で実装が簡単です。

  • stemmingが使用される主な理由は何ですか?

    -stemmingは主に検索エンジンや情報検索、次元削減、および機械学習モデルのパフォーマンス向上に役立ちます。異なる形態の単語を語幹に統一することで、検索結果の関連性や精度を高め、特徴の数を削減してモデルのパフォーマンスを向上させます。

  • Porter Stemmerとは何ですか?

    -Porter Stemmerは最も広く使われているstemmingアルゴリズムの一つです。単語の子音と母音を特定し、それに基づいて置換や削除を行って単語を語幹に戻します。

  • Snowball stemmerはPorter Stemmerとどのように異なりますか?

    -Snowball stemmerはPorter stemmerの多言語対応バージョンであり、英語以外の言語でも使用できます。また、NLTKのSnowball stemmerは「stop words」を除去する機能も持っています。

  • stemmingの主な課題とは何ですか?

    -stemmingの主な課題にはover-stemming(過剰なstemming)とunder-stemming(不十分なstemming)が含まれます。これにより、単語が意味を失うか、誤った語幹に分類されることがあります。

  • stemmingはどのようにして固有名詞の認識に悪影響を与える可能性がありますか?

    -stemmingは固有名詞を誤った語幹に分類する可能性があり、例えば「Boeing」を「Boe」に誤って削減する可能性があります。これは固有名詞の認識に悪影響を与えることがあります。

  • stemmingはどのような言語での適用に課題がありますか?

    -stemmingはアラビア語のように複雑な形態を持つ言語での適用に課題があります。stemmingアルゴリズムは接尾辞や接頭辞を正確に理解することが難しいためです。

  • stemmingとlemmatization、どちらを選択すべきかはどのように判断されますか?

    -選択はユースケースによります。高精度が必要な場合、計算コストが高いlemmatizationを選択します。一方で実装が簡単で精度を若干犠牲にしても良い場合は、stemmingを選択します。

Outlines

00:00

🌿 ステミングの基礎

この段落では、植物の茎と言葉のステムとの類似性から始まり、ステミングという言葉の前処理技術について説明しています。ステミングは自然言語処理(NLP)の一環であり、コンピュータがテキストや音声を理解するための手法です。文章をトークン化し、各単語を基本形に還元するプロセスです。例えば、「connect」という語彙の様々な形態を「connect」に還元することで、検索エンジンが関連性の高い結果を提供する仕組みを解説しています。また、ステミングとレマティゼーションの違いについても触れており、ステミングは単語の末端を削って基本形を推測する一方で、レマティゼーションは辞書にある正しい形態を取得します。

05:02

🔍 ステミングとレマティゼーションの比較

第二段落では、ステミングとレマティゼーションの技術的な違いと使用場面について詳述しています。ステミングは単語の末端を削る単純な手法であり、レマティゼーションはより正確な形態を取得するが、コンピュータリソースを多く消費します。WordNetという辞書データベースを用いて、レマティゼーションは単語の文脈や品詞情報を活用して正しい基本形を特定します。ステミングは実装が簡単である反面、レマティゼーションは正確性が高いが計算コストが高いというトレードオフがあります。

10:03

🛠 ステミングの応用

第三段落では、ステミングがどのような場面で有用であるかについて解説しています。検索エンジンや情報検索において、ステミングは単語の様々な形態を基本形に還元し、関連性の高い結果を提供するのに役立ちます。また、次元削減にも利用され、文書中のユニークな単語数を削減して機械学習モデルの性能を向上させることができます。さらに、Porter Stemmerという具体的なステミングアルゴリズムの動作についても説明しており、単語の音素を分析し、特定のパターンに従って単語を還元するプロセスを紹介しています。

15:06

🚫 ステミングの限界

最後の段落では、ステミングアルゴリズムの限界や課題について触れています。Porter Stemmerの例として「therefore」という単語を用いて、アルゴリズムが誤った基本形を生成する可能性があることを示しています。さらに、Snowball StemmerというPorter Stemmerの多言語対応版も紹介されており、NLTKというPythonのNLPライブラリを使って実装できます。また、ステミングが適切でない例として固有名詞の扱いや同音異義語の問題についても説明しています。最後に、ステミングが適切でない言語例としてアラビア語が挙げられていますが、この段落では詳細は省略されています。

Mindmap

Keywords

💡stem

「stem」とは、植物においては葉や花、果実につながる中心となる部分を指し、言葉においては語幹を意味します。ビデオではstemを用いて、言葉の基本形を見つけるプロセスを説明しています。例えば、「connect」という語幹から派生した「connected」、「connection」、「connects」などの言葉を例に挙げています。

💡stemming

「stemming」とは、テキストの前処理技術の一つであり、自然言語処理(NLP)分野で用いられます。stemmingは言葉をその基本形に還元するプロセスで、例えば「invest」という言葉に対する検索クエリでは、関連する様々な形態の言葉も検索結果に含まれます。stemmingは、検索エンジンや情報検索の効率を高めるために重要な役割を果たしています。

💡natural language processing (NLP)

「natural language processing」とは、人工知能のサブ分野であり、コンピュータがテキストや音声を使って人間と同じようにコミュニケーションを取る方法を理解する技術です。ビデオではNLPがどのように文書を小さなコンポーネントに分割し、それを機械にとってより易消化なものに変えるかを説明しています。

💡tokenization

「tokenization」とは、データセットを文書から段落、文、単語へと分割するプロセスを指します。このプロセスによって、単語が「tokens」と呼ばれる小さな単位に分けられ、それらの単語をstemmingなどの技術が扱う対象となります。

💡lemmatization

「lemmatization」とは、stemmingと同様のテキスト前処理技術で、単語を辞書に存在する正規化された形に変换するプロセスです。lemmatizationはstemmingと比べてコンテキストを必要とし、より正確ですが、計算コストが高くなります。ビデオでは、stemmingとlemmatizationの相違点を説明しています。

💡Porter Stemmer

「Porter Stemmer」とは、最も広く使われているstemmingアルゴリズムの一つであり、単語の子音と母音を特定し、それに応じた置換や削除を行います。ビデオでは「caresses」という言葉を例に、Porter Stemmerがどのようにstemを導くかを説明しています。

💡Snowball stemmer

「Snowball stemmer」はPorter Stemmerをもとにした改良されたstemmingアルゴリズムで、多言語に対応しています。PythonのNLTKパッケージを使って実装され、英語以外の言語でもstemmingを行うことができます。ビデオではSnowball stemmerがPorter Stemmerと異なる点について触れています。

💡over-stemming

「over-stemming」とは、stemmingプロセスで単語から余計に多くの部分を削除し、意味を失わせてしまう問題を指します。ビデオでは「universal」、「universe」、「university」という言葉を例に、over-stemmingがどのようにstemmingの正確性に影響するかを説明しています。

💡under-stemming

「under-stemming」とは、stemmingプロセスで単語から十分に削除されておらず、異なる意味を持つ単語が同じstemを持つという問題を指します。ビデオでは「alumnus」、「alumna」、「alumni」という言葉を例に、under-stemmingがstemmingの正確性に与える影響について説明しています。

💡homonyms

「homonyms」とは、異なる意味を持つが発音が同じ言葉を指します。ビデオでは「rose」という言葉を例に、茎言葉として「rise」を得ると説明していますが、これは花の「rose」と日の出の「rose」という異なる意味を持つ言葉に対して正しくないことを指摘しています。

Highlights

植物和单词共同点的谜题:它们都有词干(stems)。

单词的词干是连接单词不同形态的基础形式,如'connect'是'connected'、'connection'、'connects'的词干。

词干提取(Stemming)是减少单词到其基础形式的过程,常用于搜索引擎中以提供相关搜索结果。

词干提取是自然语言处理(NLP)中的文本预处理技术,NLP是人工智能的一个子领域。

NLP包括将文档分解为更小的组成部分,如段落、句子和单词(tokens)。

词干提取在单词(tokens)层面上操作,用于简化单词到其基本形式。

词干提取与词形还原(Lemmatization)的区别:词干提取通过剪切单词末端来寻找词干,而词形还原寻找标准词典形式。

词干提取是一种启发式算法,基于规则,而词形还原需要更多上下文信息。

词形还原使用WordNet这样的资源来确定单词的准确词形。

词干提取实现简单,但准确性较低;词形还原计算成本高,但准确性高。

词干提取适用于搜索引擎和信息检索,提高搜索结果的相关性和准确性。

词干提取还用于降维,减少机器学习模型中的特征数量,提高性能。

Porter词干提取算法通过识别单词中的辅音和元音,然后根据辅音和元音对的数量进行替换和消除。

Porter词干提取算法的一个例子是将'caresses'简化为'caress'。

Porter词干提取算法的局限性示例:'therefore'被错误地简化为'therefor'。

Snowball词干提取算法是Porter词干提取算法的多语言版本,可以在NLTK中使用。

词干提取的常见问题包括过度简化(overstemming)和不足简化(understemming)。

词干提取在命名实体识别和处理同音词时可能会遇到问题。

尽管存在局限性,词干提取仍然是一个简单而强大的技术,特别是在适当的应用场景中。

Transcripts

play00:00

What do plants and words have in common?

play00:03

I'll give you a hint.

play00:05

It's on the whiteboard.

play00:07

Both of them have stems.

play00:11

For a plant, the stem is the central part that connects it to the leaves,

play00:16

the flowers, the fruits.

play00:18

And for a word, each of the words have stems too.

play00:21

Today we'll be talking about stemming.

play00:25

Consider what this word "connect".

play00:28

This is a stem for words like connected, connection, connects,

play00:35

and of course, the word connect itself.

play00:38

Reducing each of these different words that I've listed over here to connect

play00:43

is the process of stemming,

play00:44

in which case the connect is the base form of the word.

play00:50

Let's say, for instance, you want to become a millionaire.

play00:53

Honestly, who doesn't?

play00:57

So what's the first step that you take to know how to be a millionaire?

play01:02

Lot of questions, right?

play01:04

Perhaps you start off with a search query.

play01:07

You pull up your favorite search engine,

play01:09

and you type in "how to invest so that I can become a millionaire".

play01:14

And what you'll notice is the search results that pop up

play01:17

don't just have the word invest,

play01:19

but also have words related to invest

play01:23

like invested, invest, investment, and so on.

play01:30

The process that is making all of this happen,

play01:32

so that you can receive relevant search results

play01:35

which cover all the different variations and all the different forms of the words,

play01:40

like invest in this case, is stemming.

play01:43

That's what the magic is.

play01:47

So today we'll be seeing about stemming, what it entails, how it's used,

play01:53

comparing it with another alternative,

play01:55

seeing an algorithm of stemming, which is called a stemmer, in action

play01:59

and ending with some caveats.

play02:02

Stemming is a text pre-processing technique

play02:04

that's used in natural language processing.

play02:07

Natural language processing, or NLP, is a sub-branch of artificial intelligence.

play02:12

It's the way our computers, machines, can understand how you and I communicate

play02:17

using text or speech.

play02:20

Natural language processing includes different tasks

play02:23

to take all of our documents, or all of our data set,

play02:27

and break it down into smaller components.

play02:30

Let's say you have a set of documents.

play02:37

You continue breaking it down into smaller components

play02:39

to make it more easily digestible for your machine.

play02:44

So each document can be broken down into paragraphs.

play02:47

Each paragraph can be broken down into sentences.

play02:54

And finally, each sentence can be broken down into different words.

play03:00

And these words over here are what are called as tokens.

play03:05

And this entire process that we have done of taking the data set from the documents

play03:09

to the paragraph, to the sentences to the words,

play03:12

is called tokenization.

play03:14

Stemming as a technique operates at the level of tokens.

play03:18

And now we'll take a deeper look into how that looks.

play03:22

So you caught a glimpse of stemming,

play03:24

but there's also another text pre-processing technique called lemmatization.

play03:29

Let's take a look at the differences between the two.

play03:32

Stemming tries to cut the ends of the word

play03:35

in the hope of getting to its base word, or its stem.

play03:39

In this case, happy - would cut the "y" and make it "happi".

play03:49

But in lemmatization, it tries to get to the normalized form of a word.

play03:53

That is, the word form that already exists in the dictionary, in which case "happy"

play04:01

will just stay "happy".

play04:07

As you can imagine, stemming is more of a heuristic algorithm

play04:11

and is very rules based.

play04:13

It looks at the ends of the word

play04:15

and tries to guess or tries to estimate what the base word could be.

play04:20

For example, it would look at words ending in "ing"

play04:24

and remove the "ing" to get the base form, which in this case works.

play04:31

However, consider the word "nothing".

play04:37

It tries to apply the same logic to it and you end up with "noth".

play04:43

Which is not really correct.

play04:45

Lemmatization, on the other hand, would actually give you "nothing".

play04:51

But the caveat here is that it requires more context.

play04:55

It requires information like part of the speech,

play04:58

the context of the word, how it's being used.

play05:02

And it uses all of that with relation to something called WordNet.

play05:07

WordNet is a huge graph which gives you relationships amongst different words,

play05:12

the synonyms, the type of definitions that they have, so on and so forth.

play05:17

That goes to say that stemming is fairly easy,

play05:22

and simple to implement.

play05:25

Whereas lemmatization is computationally more expensive.

play05:30

But also more accurate.

play05:34

Think of an example where you have the word "better".

play05:41

The stem of it would result in better, which is also incorrect.

play05:47

But lemmatization,

play05:48

powered with that additional context and additional knowledge,

play05:52

would actually be able to tell us that better is a form of "good".

play05:57

Choosing one or the other really depends on your use case.

play06:01

If you want high accuracy

play06:03

but you are okay with compromising on it being computationally expensive,

play06:07

go with lemmatization.

play06:09

If you want that something that's simpler and easier to implement,

play06:13

while compromising on accuracy a little bit, go with stemming.

play06:17

Now let's see what the use cases of stemming are.

play06:22

Why should we use stemming?

play06:25

First one is search engine, or information retrieval.

play06:30

Think back to our example of wanting to become a millionaire

play06:34

and putting in a search query of "how to invest to become a millionaire".

play06:39

Even though your query has the word "invest",

play06:42

the search results and documents that come up

play06:44

has the word "investment", or maybe "investing" or "invest".

play06:50

This is where stemming comes into play.

play06:52

Trying to get all of those different forms.

play06:55

Different morphological variants of that particular word "invest".

play07:00

This in turn gives you more relevant results,

play07:02

thereby increasing the efficiency of the search.

play07:07

While also increasing the accuracy of the results that you get.

play07:15

The next use is dimensionality reduction.

play07:21

All of the different unique words that exist in your documents

play07:25

is what comprises the vocabulary, the entire vocabulary.

play07:29

Let's say, for instance, you have "change", "changing", "unchanged" in the vocabulary.

play07:37

Which are three unique words making your vocabulary size three.

play07:43

If instead you were to use only the stem for it,

play07:47

which in this case is "change",

play07:51

your vocabulary would now reduce to just one word.

play07:55

This leads to a reduction in dimensions

play07:58

or the number of features that your machine learning model will now have.

play08:03

It again increases the accuracy as well as the procession.

play08:11

This helps you get better performances with statistical NLP models,

play08:16

especially the ones concerned with word embeddings and topic models.

play08:21

Well, enough talk about all of this.

play08:24

Let's go and see how exactly a stemming algorithm, or "stemmer", works.

play08:30

So hopefully you're on board with stemming,

play08:33

but now let's see the algorithm in action.

play08:36

A stemmer is what a stemming algorithm is called.

play08:40

And let's see how that works.

play08:42

One of the most widely used stemmers is called "Porter Stemmer",

play08:47

and the way it works is that it looks at each word

play08:51

and identifies the consonants and vowels present in there,

play08:54

and then it does a bunch of substitutions, eleminations,

play08:59

based on the number of consonants and vowel pairs present in that.

play09:03

Let's say, for example, we have the word "caresses".

play09:10

And these are the three rules that might apply to "caresses".

play09:14

You look at "sses" present and replace it with "ss".

play09:18

Or you look at "ss" present and keep it the same.

play09:21

Don't replace it.

play09:22

Or you ou look at "s" and just eliminate it.

play09:24

That is, replace it with nothing.

play09:27

As you can see, for the word "caresses",

play09:30

more than one of these rules would apply.

play09:33

But the trick over here is to look at the longest matching substring.

play09:37

Which in our case is "sses".

play09:40

And apply the first rule over here.

play09:44

So this will then become "caress", which is correct.

play09:49

Let's say instead the word was "caress".

play09:52

In that case, "ss" would stay the same,

play09:55

which is again "caress", which is also correct.

play09:59

However, nothing in life is perfect,

play10:02

and the same goes for the Porter Stemmer.

play10:05

Let's look at one example which showcases the limitation that the stemmer has.

play10:11

Consider the word "therefore".

play10:13

I've identified each of the consonants and vowels present in this particular word.

play10:19

Let's look at these.

play10:21

So two consonants coming together,

play10:23

we can collapse them and make them one.

play10:26

So that's "c".

play10:27

Let's also look at the pairs of VC's that is a vowel and a consonant coming together.

play10:33

As you can see, there are three of those occurrences.

play10:37

One, two and three,

play10:39

in which case we would denote it as VC raised to the power,

play10:44

the number of times that appears, in this case three.

play10:48

And finally ending with the V over here.

play10:52

This particular exponent, three over here, is called as measurement.

play10:58

And based on the algorithm there are certain rules that apply to the exponent.

play11:04

One of such rules, like the ones that we saw over here,

play11:07

says that if the exponent is non-zero, which means it is greater than zero,

play11:14

which it is for our case,

play11:17

and if the word in consideration ends with an "e",

play11:21

you must eliminate "e".

play11:25

Which then gives us this as our stem,

play11:30

"therefor(e)" minus the "e", which is incorrect.

play11:34

Even though this is a limitation of the Porter stemming algorithm,

play11:38

the Porter stemmer still remains one of the most widely used

play11:42

because of the amount of rules that it has

play11:45

and the amount of correct results it does give,

play11:48

even if stemming as a whole is heuristic and simplistic in nature.

play11:54

Another stemmer that you might have heard of is called the Snowball stemmer.

play11:58

It's a modification of the Porter stemmer.

play12:01

The Porter stemmer was created only to be used with English words.

play12:06

However, the Snowball stemmer is multilinguistic,

play12:09

which means it does work on languages other than English.

play12:14

The pythonic implementation of Snowball stemmer,

play12:17

which you can use using NLTK, which stands for Natural Language Toolkit,

play12:22

which is an NLP package available,

play12:25

has Snowball stemmer in the event where you can use it to remove "stop words".

play12:32

So stop words would then be eliminated from the process of stemming.

play12:36

So those are two ways that the Snowball stemmer is different from Porter Stemmer.

play12:42

Let's continue looking at some more issues and limitations that exist with stemming.

play12:47

Two of the most common issues that arise with stemming

play12:51

are overstemming and understemming.

play12:54

Let's take a look at some examples.

play12:57

Considers "universal", "universe" and "university".

play13:01

Overstemming, as it sounds, over does the stemming part,

play13:05

or removes too much, more than necessary,

play13:08

to the point where the words can lose meaning themselves.

play13:12

The stem for each of those would be

play13:17

"universe" without the "e" ("univers"),

play13:20

And based on our knowledge of the English language,

play13:23

we know that this is incorrect because universal, universe and university

play13:28

are three words that mean totally different things.

play13:32

The opposite end of this is "understemming",

play13:35

where not enough removal has happened.

play13:38

Consider the example of "alumnus", "alumna", and "alumni".

play13:43

"Alumna" and "alumni" would remain the same,

play13:46

whereas "alumnus" would become "alumna",

play13:49

giving us three different stems, or three different base words.

play13:54

Which in this case is also incorrect,

play13:57

because each of these three words mean the same thing,

play14:01

and so should have the same stem.

play14:05

Some of the other challenges that exist with stemming are:

play14:10

it fares badly with named entity recognition.

play14:14

For example, you might have some proper nouns.

play14:18

Consider "Boeing".

play14:22

Based on the examples that we have seen previously,

play14:25

stemming would reduce the "ing" from it,

play14:29

giving you the stem of "Boe",

play14:32

which we know is incorrect because it's a proper noun.

play14:36

Another example might be that of homonyms.

play14:40

Consider "rose" the flower,

play14:43

and "rose", sun rising - the past tense of "rise".

play14:49

In this case too, the stemming algorithm

play14:52

would inaccurately get the stem for each of those as "rise".

play14:59

Which does make sense for the sun rose,

play15:02

but does not make sense for the flower rose.

play15:05

You might also run into issues trying to attempt stemming

play15:09

on languages like Arabic,

play15:11

which have complex forms present, as it can be difficult to understand

play15:16

what suffixes and what prefixes are present.

play15:22

Stemming is a simple yet powerful technique when used in the right way.

play15:27

Hopefully you learned something useful along this way

play15:31

when we talked about stemming,

play15:33

and this has continued to grow strong roots

play15:37

as you go on in your journey of artificial intelligence.

play15:42

If you like this video and want to see more like it,

play15:45

please like and subscribe.

play15:48

If you have any questions or want to share your thoughts about this topic,

play15:52

please leave a comment below.

Rate This

5.0 / 5 (0 votes)

Related Tags
stemminglemmatization自然言語処理情報検索テキスト解析Porter StemmerSnowball Stemmer言語モデル機械学習AI技術テキスト前処理
Do you need a summary in English?