没有合适的资源?快使用搜索试试~ 我知道了~
# -*- coding: utf-8 -*- """ Created on Mon May 7 19:43:04 2018 @author: Administrator """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections import tensorflow as tf import os import numpy as np def _read_words(filename): with tf.gfile.GFile(filename, "r") as f: return f.read().replace("\n", "<eos>").split() def _build_vocab(filename): data = _read_words(filename) counter = collections.Counter(data) count_pairs = sorted(counter.items(), key=lambda x: (-x[1], x[0])) words, _ = list(zip(*count_pairs)) word_to_id = dict(zip(words, range(len(words)))) return word_to_id
资源推荐
资源评论
资源评论
LLYYSSDDGG
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功