Main Content

문서의 철자 교정하기

이 예제에서는 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"가 "words"로 변경되었습니다.

  • 입력 단어 "lemmatization"이 "solemnization"으로 변경되었습니다.

  • 입력 단어 "Analytics"가 "Analytic"으로 변경되었습니다.

  • 입력 단어 "providesfunctions"가 두 단어 "provides"와 "functions"로 분할되었습니다.

사용자 지정 단어 지정하기

correctSpelling 함수의 'KnownWords' 옵션을 사용하여 알려진 단어 목록을 제공하면 특정 단어가 업데이트되지 않도록 방지할 수 있습니다.

문서 철자를 다시 교정한 다음 단어 "MATLAB", "Analytics" 및 "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", "Analytics", "lemmatization"이 변경되지 않았음을 알 수 있습니다.

참고 항목

|

관련 항목