def _create_matrix(self, document, dictionary):
        """
        Creates matrix of shape |unique words|×|sentences| where cells
        contains number of occurences of words (rows) in senteces (cols).
        """
        sentences = document.sentences

        words_count = len(dictionary)
        sentences_count = len(sentences)
        if words_count < sentences_count:
            message = (
                "Number of words (%d) is lower than number of sentences (%d). "
                "LSA algorithm may not work properly."
            )
            warn(message % (words_count, sentences_count))

        # create matrix |unique words|×|sentences| filled with zeroes
        matrix = numpy.zeros((words_count, sentences_count))
        for col, sentence in enumerate(sentences):
            for word in map(self.stem_word, sentence.words):
                # only valid words is counted (not stop-words, ...)
                if word in dictionary:
                    row = dictionary[word]
                    matrix[row, col] += 1

        return matrix
def _create_matrix ( self , document , dictionary ) : sentences = document . sentences words_count = len ( dictionary ) sentences_count = len ( sentences ) if words_count < sentences_count : message = ( "Number of words (%d) is lower than number of sentences (%d). " "LSA algorithm may not work properly." ) warn ( message % ( words_count , sentences_count ) ) matrix = numpy . zeros ( ( words_count , sentences_count ) ) for col , sentence in enumerate ( sentences ) : for word in map ( self . stem_word , sentence . words ) : if word in dictionary : row = dictionary [ word ] matrix [ row , col ] += 1 return matrix
Creates matrix of shape |unique words|×|sentences| where cells
        contains number of occurences of words (rows) in senteces (cols).