def extract_master_keyword(self, title, article):
        assert article != None, 'article is invalid'
        assert len(article) > 0, 'article is invalid'

        title_morpheme_list = self._morpheme_analyzer.analyze_morpheme(title)
        title_keywords = [
            morpheme.morpheme for morpheme in title_morpheme_list
        ]

        article_morpheme_list = self._morpheme_analyzer.analyze_morpheme(
            article)
        #article_morpheme_list = filter(lambda x:x.frequency > 1, article_morpheme_list)

        article_matrix = self._create_article_matrix(article,
                                                     article_morpheme_list)

        if not isinstance(article_matrix, ndarray):
            return None

        pca = PCANode(svd=True)
        try:
            pca.execute(article_matrix)
        except Exception, e:
            print str(e), title
            logging.exception(
                'Exception raised in method extract_master_keyword with article title='
                + title)
Пример #2
0
def PCA():
	col1 = np.array([[1.0, 2, 3, 4, 5, 6, 7, 8, 9]]).T
	col2 = np.array([[2.0, 4, 6, 8, 10, 12, 14, 16, 18]]).T
	matr12 = np.hstack((col1, col2))
	matr_arr = [matr12]
	pca_node = PCANode()
	d_arr = []

	for arr in matr_arr:
		result = pca_node.execute(arr)
		d_arr.append(pca_node.d)
		print pca_node.d