Main Content

removeEmptyDocuments

토큰화된 문서 배열, bag-of-words 모델 또는 bag-of-n-grams 모델에서 빈 문서 제거

설명

예제

newDocuments = removeEmptyDocuments(documents)documents에서 단어가 없는 문서를 제거합니다.

예제

newBag = removeEmptyDocuments(bag)는 bag-of-words 또는 bag-of-n-grams 모델 bag에서 단어나 n-gram이 없는 문서를 제거합니다.

예제

[___,idx] = removeEmptyDocuments(___)는 제거된 문서의 인덱스도 반환합니다.

예제

모두 축소

토큰화된 문서로 구성된 배열에서 단어가 없는 문서를 제거합니다.

빈 문서가 포함된 토큰화된 문서로 구성된 배열을 만듭니다.

documents = tokenizedDocument([
    "an example of a short sentence"
    ""
    "a second short sentence"
    ""])
documents = 
  4x1 tokenizedDocument:

    6 tokens: an example of a short sentence
    0 tokens:
    4 tokens: a second short sentence
    0 tokens:

빈 문서를 제거합니다.

newDocuments = removeEmptyDocuments(documents)
newDocuments = 
  2x1 tokenizedDocument:

    6 tokens: an example of a short sentence
    4 tokens: a second short sentence

bag-of-words 모델에서 단어를 포함하지 않는 문서를 제거합니다.

토큰화된 문서로 구성된 배열에서 bag-of-words 모델을 만듭니다.

documents = tokenizedDocument([
    "An example of a short sentence."
    ""
    "A second short sentence."
    ""]);
bag = bagOfWords(documents)
bag = 
  bagOfWords with properties:

          Counts: [4x9 double]
      Vocabulary: ["An"    "example"    "of"    "a"    "short"    "sentence"    "."    "A"    "second"]
        NumWords: 9
    NumDocuments: 4

bag-of-words 모델에서 빈 문서를 제거합니다.

newBag = removeEmptyDocuments(bag)
newBag = 
  bagOfWords with properties:

          Counts: [2x9 double]
      Vocabulary: ["An"    "example"    "of"    "a"    "short"    "sentence"    "."    "A"    "second"]
        NumWords: 9
    NumDocuments: 2

배열에서 단어가 없는 문서를 제거하고, 제거된 문서의 인덱스를 사용하여 해당 레이블도 제거합니다.

빈 문서가 포함된 토큰화된 문서로 구성된 배열을 만듭니다.

documents = tokenizedDocument([
    "an example of a short sentence"
    ""
    "a second short sentence"
    ""])
documents = 
  4x1 tokenizedDocument:

    6 tokens: an example of a short sentence
    0 tokens:
    4 tokens: a second short sentence
    0 tokens:

레이블로 구성된 벡터를 만듭니다.

labels = ["T"; "F"; "F"; "T"]
labels = 4x1 string
    "T"
    "F"
    "F"
    "T"

빈 문서를 제거하고 제거된 문서의 인덱스를 가져옵니다.

[newDocuments, idx] = removeEmptyDocuments(documents)
newDocuments = 
  2x1 tokenizedDocument:

    6 tokens: an example of a short sentence
    4 tokens: a second short sentence

idx = 2×1

     2
     4

labels에서 해당 레이블을 제거합니다.

labels(idx) = []
labels = 2x1 string
    "T"
    "F"

입력 인수

모두 축소

입력 문서로, tokenizedDocument 배열로 지정됩니다.

입력 bag-of-words 모델 또는 bag-of-n-grams 모델로, bagOfWords 객체 또는 bagOfNgrams 객체로 지정됩니다.

출력 인수

모두 축소

출력 문서로, tokenizedDocument 배열로 반환됩니다.

출력 모델로, bagOfWords 객체 또는 bagOfNgrams 객체로 반환됩니다. newBag의 유형은 bag의 유형과 같습니다.

제거된 문서의 인덱스로, 양의 정수로 구성된 벡터로 반환됩니다.

버전 내역

R2017b에 개발됨