栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

讯飞汽车领域多语种迁移学习 打卡博客

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

讯飞汽车领域多语种迁移学习 打卡博客

任务1:报名比赛
  • 步骤1:报名比赛2022 iFLYTEK A.I.开发者大赛-讯飞开放平台
  • 步骤2:下载比赛数据(点击比赛页面的赛题数据)
  • 步骤3:解压比赛数据,并使用pandas进行读取;
  • 步骤4:查看训练集和测试集字段类型,并将数据读取代码写到博客;
import pandas as pd
import numpy as np


#任务一:读取数据
train_cn = pd.read_excel('data/中文_train.xlsx')
train_en = pd.read_excel('data/英文_train.xlsx')
train_jp = pd.read_excel('data/日语_train.xlsx')
test_jp = pd.read_excel('data/test_A.xlsx', sheet_name='日语_testA')
test_en = pd.read_excel('data/test_A.xlsx', sheet_name='英文_testA')
#查看数据
print(train_cn.head())
原始文本意图槽值1槽值2
016.5度adjust_ac_temperature_to_numberoffset:16.5NaN
116度adjust_ac_temperature_to_numberoffset:16NaN
216空调开到16度adjust_ac_temperature_to_numberoffset:16NaN
316温度16度adjust_ac_temperature_to_numberoffset:16NaN
417度adjust_ac_temperature_to_numberoffset:17NaN
print(train_en.head())
原始文本中文翻译意图槽值1槽值2
0open aircon please请打开空调open_acNANNAN
1I want to activate the AC我想打开空调open_acNANNAN
2I want to turn on the air conditioner我想打开空调open_acNANNAN
3switch on the AC please请打开空调open_acNANNAN
4Help me open the AC帮我打开空调open_acNANNAN
print(train_jp.head())
原始文本中文翻译意图槽值1槽值2
0エアコンのスイッチONに打开空调开关open_acNANNAN
1エアコン入れる打开空调open_acNANNAN
2エアコンのスイッチを打开空调开关open_acNANNAN
3エアコンのスイッチ入れる打开空调开关open_acNANNAN
4エアコンのスイッチON打开空调开关open_acNANNAN
#查看测试集数据
print(test_jp.head())
print(test_en.head())
原始文本
0switch on the AC
1air conditioner open
2Turn on the AC please
3I wanna switch on aircon please
4Help me switch on aircon
任务2:文本分析与文本分词
  • 步骤1:使用jieba对中文进行分词;
    import jieba
    
    
    def cutwords(txt):
        return jieba.lcut(txt)
    
    
    train_cn['phrase'] = train_cn['原始文本'].apply(cutwords)
    print(train_cn.head())

    lcut 将返回的对象转化为list对象返回

  • 步骤2:使用negisa对日语进行分词
    import nagisa
    def cutjpwords(txt):
        words = nagisa.tagging(txt)
        return words.words
    
    
    train_jp['phrase'] = train_jp['原始文本'].apply(cutjpwords)
    
    print(train_jp.head())

     

  • 任务3:TFIDF与文本分类
    • 步骤1:学习TFIDF的使用,提取语料的TFIDF特征;
    • 步骤2:使用逻辑回归结合TFIDF进行训练(所有的语言语料),并对测试集的意图进行分类;
    • 步骤3:将步骤2预测的结果文件提交到比赛,截图分数;
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/998212.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号