This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
from gensim.models.fasttext import FastText | |
# [ ['你', '好', '吗'] ] | |
sentences = pickle.load(open('./x.pkl', 'rb')) | |
model = FastText(size=64, window=10, min_count=1) | |
model.build_vocab(sentences=sentences) | |
model.train(sentences=sentences, total_examples=len(sentences), epochs=10) | |
model.wv.save_word2vec_format('./fasttext64.txt') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reference: | |
http://www.hankcs.com/nlp/textrank-algorithm-to-extract-the-keywords-java-implementation.html | |
http://www.hankcs.com/nlp/textrank-algorithm-java-implementation-of-automatic-abstract.html | |
Chinese Embedding From | |
https://github.com/Embedding/Chinese-Word-Vectors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reference: | |
http://www.hankcs.com/nlp/textrank-algorithm-to-extract-the-keywords-java-implementation.html | |
http://www.hankcs.com/nlp/textrank-algorithm-java-implementation-of-automatic-abstract.html | |
Chinese Embedding From | |
https://github.com/Embedding/Chinese-Word-Vectors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reference: | |
http://www.hankcs.com/nlp/textrank-algorithm-to-extract-the-keywords-java-implementation.html | |
http://www.hankcs.com/nlp/textrank-algorithm-java-implementation-of-automatic-abstract.html | |
""" | |
from gensim.summarization.bm25 import get_bm25_weights | |
import numpy as np | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reference: | |
http://www.hankcs.com/nlp/textrank-algorithm-to-extract-the-keywords-java-implementation.html | |
http://www.hankcs.com/nlp/textrank-algorithm-java-implementation-of-automatic-abstract.html | |
""" | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def global_max_pooling(tensor, dim, topk): | |
"""Global max pooling""" | |
ret, _ = torch.topk(tensor, topk, dim) | |
return ret |