Main Content

removeDocument

bag-of-words 모델 또는 bag-of-n-grams 모델에서 문서 제거

설명

예제

newBag = removeDocument(bag,idx)idx로 지정된 인덱스를 갖는 문서를 bag-of-words 모델 또는 bag-of-n-grams 모델 bag에서 제거합니다. 제거된 문서에 나머지 문서에는 없는 단어나 n-gram이 들어 있는 경우 이 함수는 그러한 단어나 n-gram도 bag에서 제거합니다.

예제

모두 축소

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

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

          Counts: [4x9 double]
      Vocabulary: ["an"    "example"    "of"    "a"    "short"    "sentence"    "second"    "third"    "final"]
        NumWords: 9
    NumDocuments: 4

bag에서 첫 번째 문서와 세 번째 문서를 제거합니다.

idx = [1 3];
newBag = removeDocument(bag,idx)
newBag = 
  bagOfWords with properties:

          Counts: [2x5 double]
      Vocabulary: ["a"    "short"    "sentence"    "second"    "final"]
        NumWords: 5
    NumDocuments: 2

논리형 인덱스를 사용하여 동일한 문서를 제거합니다.

idx = logical([1 0 1 0]);
newBag = removeDocument(bag,idx)
newBag = 
  bagOfWords with properties:

          Counts: [2x5 double]
      Vocabulary: ["a"    "short"    "sentence"    "second"    "final"]
        NumWords: 5
    NumDocuments: 2

입력 인수

모두 축소

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

제거할 문서의 인덱스로, 숫자형 인덱스로 구성된 벡터 또는 논리형 인덱스로 구성된 벡터로 지정됩니다.

예: [2 4 6]

예: [0 1 0 1 0 1]

출력 인수

모두 축소

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

버전 내역

R2017b에 개발됨