Sample usage for bleu¶
BLEU tests¶
>>> from nltk.translate import bleu
This is an implementation of the smoothing techniques for segment-level BLEU scores that was presented in Boxing Chen and Collin Cherry (2014) A Systematic Comparison of Smoothing Techniques for Sentence-Level BLEU. In WMT14. http://acl2014.org/acl2014/W14-33/pdf/W14-3346.pdf >>> from nltk.translate.bleu_score import sentence_bleu,SmoothingFunction
>>> sentence_bleu(
... ['It is a place of quiet contemplation .'.split()],
... 'It is .'.split(),
... smoothing_function=SmoothingFunction().method4,
... )*100
4.4267...
clusters = {}
for word, label in zip(model.wv.index_to_key, egg.labels_):
clusters[word] = label
list_of_cl = []
for i in range(n_cl):
words = [word for word, label in clusters.items() if label == i]
list_of_cl.append(words)
print('Cluster:', i+1)
print(words)
print()
# Импортирование библиотеки для работы с данными
import pandas as pd
# Выгрузка данных из таблицы
data = pd.read_csv(r"", sep='^')
# Генерирование 2ух мерного списка навыков
sents = [sent.split(';') for sent in data['Навыки']]
# Импортирование библиотеки FastText
from gensim.models.fasttext import FastText
# Определение параметров обучения
window_size = 5
down_sampling = 1e-3
# Обучение модели FastText на 2ух мерном списке навыков
model = FastText(sentences=sents, window=window_size, sample=down_sampling, workers = 6)
# Сохранение обученной модели
model.save(r"")