В этом примере показано, как откорректировать написание в использовании документов Hunspell.
Создайте массив маркируемых документов.
str = [
"Use MATLAB to correct spelling of words."
"Correctly spelled worrds are important for lemmatization."
"Text Analytics Toolbox providesfunctions for spelling correction."];
documents = tokenizedDocument(str)documents =
3x1 tokenizedDocument:
8 tokens: Use MATLAB to correct spelling of words .
8 tokens: Correctly spelled worrds are important for lemmatization .
8 tokens: Text Analytics Toolbox providesfunctions for spelling correction .
Откорректируйте написание документов с помощью correctSpelling функция.
updatedDocuments = correctSpelling(documents)
updatedDocuments =
3x1 tokenizedDocument:
9 tokens: Use MAT LAB to correct spelling of words .
8 tokens: Correctly spelled words are important for solemnization .
9 tokens: Text Analytic Toolbox provides functions for spelling correction .
Заметьте, что:
Входное слово "MATLAB" было разделено в эти два слова "MAT" и "LAB".
Входное слово "worrds" было изменено на "слова".
Входное слово "lemmatization" было изменено на "празднование".
Входное слово "Analytics" было изменено на "Аналитический".
Входное слово "providesfunctions" было разделено в эти два слова, "обеспечивает" и "функционирует".
Чтобы препятствовать тому, чтобы программное обеспечение обновило конкретные слова, можно предоставить список известных слов с помощью 'KnownWords' опция correctSpelling функция.
Откорректируйте написание документов снова и задайте слова "MATLAB", "Аналитика" и "lemmatization" как известные слова.
updatedDocuments = correctSpelling(documents,'KnownWords',["MATLAB" "Analytics" "lemmatization"])
updatedDocuments =
3x1 tokenizedDocument:
8 tokens: Use MATLAB to correct spelling of words .
8 tokens: Correctly spelled words are important for lemmatization .
9 tokens: Text Analytics Toolbox provides functions for spelling correction .
Заметьте здесь, что слова "MATLAB", "Аналитика" и "lemmatization" остаются неизменными.
correctSpelling | tokenizedDocument