Ai
1 Star 1 Fork 3

peiss/ant-english-translate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
english_dict.py 421 Bytes
一键复制 编辑 原始数据 按行查看 历史
cztps2 提交于 2021-09-25 23:13 +08:00 . 提交代码
import pandas as pd
class EnglishDict():
def __init__(self):
self.data_dict = None
def load_data(self, dict_path):
self.data_dict = pd.read_csv(dict_path,
usecols=["word", "translation"])
def query(self, word):
row = self.data_dict.query(f"word == '{word}'")
if row is not None and row.shape[0] > 0:
return row.iloc[0]["translation"]
return "没有查询到结果"
english_dict = EnglishDict()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/antpython/ant-english-translate.git
git@gitee.com:antpython/ant-english-translate.git
antpython
ant-english-translate
ant-english-translate
master

搜索帮助