MATLAB 도움말 센터
bag-of-n-grams 모델에서 낮은 빈도로 나오는 n-gram 제거
newBag = removeInfrequentNgrams(bag,count)
newBag = removeInfrequentNgrams(bag,count,'NgramLengths',lengths)
newBag = removeInfrequentNgrams(___,'IgnoreCase',true)
newBag = removeInfrequentNgrams(bag,count)는 bag-of-n-grams 모델 bag에서 최대 count번 나오는 n-gram을 제거합니다. 이 함수는 기본적으로 대/소문자를 구분합니다.
newBag
bag
count
예제
newBag = removeInfrequentNgrams(bag,count,'NgramLengths',lengths)는 lengths로 지정된 길이의 n-gram만 제거합니다. 이 함수는 기본적으로 대/소문자를 구분합니다.
lengths
newBag = removeInfrequentNgrams(___,'IgnoreCase',true)는 대/소문자를 구분하지 않고 최대 count번 나오는 n-gram을 제거합니다. n-gram이 대/소문자만 다른 경우 개수가 합산됩니다.
모두 축소
예제 데이터를 불러옵니다. 파일 sonnetsPreprocessed.txt에는 셰익스피어 소네트의 전처리된 버전이 들어 있습니다. 파일에는 한 줄에 하나씩 소네트가 들어 있으며 단어가 공백으로 구분되어 있습니다. sonnetsPreprocessed.txt에서 텍스트를 추출하고, 추출한 텍스트를 새 줄 문자에서 문서로 분할한 후 그 문서를 토큰화합니다.
sonnetsPreprocessed.txt
filename = "sonnetsPreprocessed.txt"; str = extractFileText(filename); textData = split(str,newline); documents = tokenizedDocument(textData);
bag-of-n-grams 모델을 만듭니다. 바이그램(두 개의 단어) 및 트라이그램(세 개의 단어) 개수를 계산하도록 지정합니다.
bag = bagOfNgrams(documents,'NgramLengths',[2 3])
bag = bagOfNgrams with properties: Ngrams: [18022×3 string] NgramLengths: [2 3] NumNgrams: 18022 Counts: [154×18022 double] Vocabulary: ["fairest" "creatures" "desire" "increase" "thereby" "beautys" "rose" "might" "never" "die" "riper" "time" "decease" "tender" "heir" "bear" "memory" "thou" … ] (1×3092 string) NumDocuments: 154
총 2번 이하로 나오는 임의 길이의 n-gram을 제거합니다.
bag = removeInfrequentNgrams(bag,2)
bag = bagOfNgrams with properties: Ngrams: [103×3 string] NgramLengths: [2 3] NumNgrams: 103 Counts: [154×103 double] Vocabulary: ["thine" "thy" "self" "sweet" "thou" "time" "why" "dost" "upon" "eye" "thee" "ten" "beauty" "love" "wilt" "dear" "truth" "own" "yet" "hast" "mens" … ] (1×73 string) NumDocuments: 154
총 4번 이하로 나오는 바이그램을 제거합니다.
bag = removeInfrequentNgrams(bag,4,'NgramLengths',2)
bag = bagOfNgrams with properties: Ngrams: [41×3 string] NgramLengths: [2 3] NumNgrams: 41 Counts: [154×41 double] Vocabulary: ["thine" "thy" "sweet" "thou" "dost" "upon" "why" "thee" "ten" "love" "dear" "hast" "true" "mine" "beauty" "fair" "own" "self" "art" "times" "shouldst" … ] (1×30 string) NumDocuments: 154
bagOfNgrams
입력 bag-of-n-grams 모델로, bagOfNgrams 객체로 지정됩니다.
개수 임계값으로, 양의 정수로 지정됩니다. 이 함수는 총 count번 이하로 나오는 n-gram을 제거합니다.
n-gram 길이로, 양의 정수 또는 양의 정수로 구성된 벡터로 지정됩니다.
lengths를 지정하면, 함수는 빈도가 낮으면서 지정된 길이를 갖는 n-gram을 제거합니다. lengths를 지정하지 않으면, 함수는 길이에 관계없이 빈도가 낮은 n-gram을 제거합니다.
예: [1 2 3]
[1 2 3]
출력 bag-of-n-grams 모델로, bagOfNgrams 객체로 반환됩니다.
R2018a에 개발됨
bagOfWords | bagOfNgrams | removeInfrequentWords | removeNgrams | removeEmptyDocuments | topkngrams | tfidf | tokenizedDocument
bagOfWords
removeInfrequentWords
removeNgrams
removeEmptyDocuments
topkngrams
tfidf
tokenizedDocument
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
유럽
아시아 태평양
지역별 지사에 문의