# -*- coding: utf-8 -*- # @Author: StudentCWZ # @Date: 2020-11-30 11:35:55 # @Last Modified by: Gree # @Last Modified time: 2020-12-18 15:35:37 import re import pandas as pd def PlayControlCheck(input_df): """ 模块功能:检查playcontrol类的语料字段domain、intent、response_text是否正确 iterrows: 返回值为元组,(index,row) """ print('The module of play_control_check is running!') for index, row in input_df.iterrows(): query = row['query'] domain = row['domain'] intent = row['intent'] response_text = row['response_text'] try: # 正则表达式匹配数据规律 query_result = re.search(r'.*?(关闭播放|关闭音乐|停止音乐|换一|下一首|别唱了|音乐关|暂停|下一曲|换歌|继续播放|换音乐|关掉音乐|上一曲|不想听|关闭歌曲|不要放|换首歌|继续唱|请切|单曲循环|关闭故事|停止播放|关掉歌曲|歌曲关掉|切音乐|上一首歌|继续的|退出音乐|音乐停止|请播放下|播放上一首|换首音乐|下一个|把停止|这首歌是|换个歌|继续播|是什么歌|请播放|播放下|关音乐|关掉关掉音乐|打开音乐|请关了音乐|不听歌了|请关关闭|把歌声关掉|关闭关闭|把音乐打开|不听了|关了音乐|取消歌曲|调最小音乐|关闭儿歌|退出播放|停止放音乐|关掉故事|继续音乐|重新播放|换个音乐|接着播放|切儿歌|继续|换首|不要音乐|歌曲关闭|歌名|这首歌|关掉歌|退出歌曲|换个音乐|换儿歌|故事关了|下一集|上一首|播放个仔停止|换个儿歌|关闭歌|停止我要听|播放音乐|停止放歌|哪个朝代的|这诗谁写的|作者是谁).*', query) if query_result is not None and '等于' not in query and '乘' not in query and '最小风' not in query and '有点冷' not in query and '查一查' not in query and '切换到一' not in query and '切换到二' not in query and '停止我要听童话故事' not in query and '停止播放我要听故事' not in query and '关闭语音暂停播放' not in query and '几点钟' not in query and '这诗' not in query: if domain == 'PlayControl' and '帮我放下' not in query and '帮我播放下' not in query and '请播放下歌' not in query and query != '是哪个朝代的' and query != '作者是谁' and query != '这首歌叫什么名字': row['domain_is_right'] = 'yes' if 'control' in intent or 'query' in intent: row['intent_is_right'] = 'yes' else: row['intent_is_right'] = 'no' try: if '学艺不精' not in response_text: row['response_is_right'] = 'yes' else: row['response_is_right'] = 'no' except: pass yield { # 'initial_id': row['id'], 'date_time': row['date_time'], 'request_id': row['request_id'], 'mac_wifi': row['mac_wifi'], 'user_id': row['user_id'], 'query': query, 'domain': domain, 'intent': intent, 'response_text': response_text, 'domain_is_right': row['domain_is_right'], 'intent_is_right': row['intent_is_right'], 'response_is_right': row['response_is_right'] } else: pass else: pass except: pass print('The module of play_control_check is executed!')