diff --git a/parlai/core/teachers.py b/parlai/core/teachers.py index 7a8055aab59..5bab000cd6c 100644 --- a/parlai/core/teachers.py +++ b/parlai/core/teachers.py @@ -1733,8 +1733,8 @@ def _get_ep_from_turns(self, xturns, yturns): turn['text'] = xturn.get('text') turn['labels'] = [yturn.get('text')] - turn['x_turn'] = xturn - turn['y_turn'] = yturn + turn['x_turn'] = dict(xturn) + turn['y_turn'] = dict(yturn) eps.append(turn) return eps @@ -1841,8 +1841,8 @@ def _validate_image_mode_name(self, a): available_model_names = self.get_available_image_mode_names() if a not in available_model_names: raise argparse.ArgumentTypeError( - '\"%s\" unknown image model name. Choose from: %s. Currently suggested resnet is resnet152 and resnext is resnext101_32x48d_wsl.' - % (a, available_model_names) + f'"{a}" unknown image model name. Choose from: {available_model_names}.' + 'Currently suggested resnet is resnet152 and resnext is resnext101_32x48d_wsl.' ) return a diff --git a/parlai/tasks/lccc/test/lccc_test.yml b/parlai/tasks/lccc/test/lccc_test.yml index 14d918d9a84..691f3d62ed9 100644 --- a/parlai/tasks/lccc/test/lccc_test.yml +++ b/parlai/tasks/lccc/test/lccc_test.yml @@ -4,25 +4,55 @@ acts: - 去相机家里吃…… id: lccc text: 我饿了。 + x_turn: + id: partner1 + text: 我饿了。 + y_turn: + id: partner2 + text: 去相机家里吃…… - - episode_done: true eval_labels: - 你过来我们什么关系 id: lccc text: 网络大实话里说的是也许你能在网络里找到你想要的友情但永远不会找到你想要的爱情 + x_turn: + id: partner1 + text: 网络大实话里说的是也许你能在网络里找到你想要的友情但永远不会找到你想要的爱情 + y_turn: + id: partner2 + text: 你过来我们什么关系 - - episode_done: true eval_labels: - 我不挑食 id: lccc text: 老铁家好吃贾三不好吃 + x_turn: + id: partner1 + text: 老铁家好吃贾三不好吃 + y_turn: + id: partner2 + text: 我不挑食 - - episode_done: true eval_labels: - 死鱼皮真会安慰人那不是翘臀是肥肉不!是赘肉! id: lccc text: 你有翘臀啊!!!!你的脸还不够小啊????? + x_turn: + id: partner1 + text: 你有翘臀啊!!!!你的脸还不够小啊????? + y_turn: + id: partner2 + text: 死鱼皮真会安慰人那不是翘臀是肥肉不!是赘肉! - - episode_done: false eval_labels: - 哈哈哈快到南方来 id: lccc text: 好羡慕原来你们那真的可以光腿 + x_turn: + id: partner1 + text: 好羡慕原来你们那真的可以光腿 + y_turn: + id: partner2 + text: 哈哈哈快到南方来 num_episodes: 10000 num_examples: 12943 diff --git a/parlai/tasks/lccc/test/lccc_train.yml b/parlai/tasks/lccc/test/lccc_train.yml index 61c92e7a6e7..a4b593a4ba3 100644 --- a/parlai/tasks/lccc/test/lccc_train.yml +++ b/parlai/tasks/lccc/test/lccc_train.yml @@ -4,25 +4,55 @@ acts: labels: - 道歉!!再有时间找你去 text: 你去那儿竟然不喊我生气了,快点给我道歉 + x_turn: + id: partner1 + text: 你去那儿竟然不喊我生气了,快点给我道歉 + y_turn: + id: partner2 + text: 道歉!!再有时间找你去 - - episode_done: true id: lccc labels: - SEED早上刚被禁用还有一个月的VIP路线呢禁了之后才买的另一个买了一年结果用了一下午就挂了现在用了个极速网速差的很 text: 我用SEED.24小时签到一次可以用4小时,对于我这种每天晚上逛一下的感觉不错 + x_turn: + id: partner1 + text: 我用SEED.24小时签到一次可以用4小时,对于我这种每天晚上逛一下的感觉不错 + y_turn: + id: partner2 + text: SEED早上刚被禁用还有一个月的VIP路线呢禁了之后才买的另一个买了一年结果用了一下午就挂了现在用了个极速网速差的很 - - episode_done: true id: lccc labels: - 干完这一票我的会员等级就要升了! text: 咬咬牙这回要全入了! + x_turn: + id: partner1 + text: 咬咬牙这回要全入了! + y_turn: + id: partner2 + text: 干完这一票我的会员等级就要升了! - - episode_done: true id: lccc labels: - 代表了哪里的普通人? text: 记得还…我们普通人要搬三天砖才赚来的20元 + x_turn: + id: partner1 + text: 记得还…我们普通人要搬三天砖才赚来的20元 + y_turn: + id: partner2 + text: 代表了哪里的普通人? - - episode_done: true id: lccc labels: - 好得差不多啦 text: 早点好起来啊。生日快乐 + x_turn: + id: partner1 + text: 早点好起来啊。生日快乐 + y_turn: + id: partner2 + text: 好得差不多啦 num_episodes: 6820506 num_examples: 8869637 diff --git a/parlai/tasks/lccc/test/lccc_valid.yml b/parlai/tasks/lccc/test/lccc_valid.yml index d165954f143..5d43888ecef 100644 --- a/parlai/tasks/lccc/test/lccc_valid.yml +++ b/parlai/tasks/lccc/test/lccc_valid.yml @@ -4,25 +4,55 @@ acts: - 那个饭凉了吧唧的怎么吃啊摔 id: lccc text: 啊我好爱虾仁蛋黄酱金枪鱼蛋黄酱 + x_turn: + id: partner1 + text: 啊我好爱虾仁蛋黄酱金枪鱼蛋黄酱 + y_turn: + id: partner2 + text: 那个饭凉了吧唧的怎么吃啊摔 - - episode_done: true eval_labels: - 看了下全文,那女的考试当天就表明身体不舒服了,考试不是她预约是教练自己安排的,教练还让她考试不就是教练的错吗?而且她住院花了31万,赔30万不过分吧 id: lccc text: 考试撞墙关驾校屁事?你怎么不顺便把考场施工单位也告了? + x_turn: + id: partner1 + text: 考试撞墙关驾校屁事?你怎么不顺便把考场施工单位也告了? + y_turn: + id: partner2 + text: 看了下全文,那女的考试当天就表明身体不舒服了,考试不是她预约是教练自己安排的,教练还让她考试不就是教练的错吗?而且她住院花了31万,赔30万不过分吧 - - episode_done: true eval_labels: - 好好好,偶遇我大闺蜜 id: lccc text: 我先去穿衣服,准备走了 + x_turn: + id: partner1 + text: 我先去穿衣服,准备走了 + y_turn: + id: partner2 + text: 好好好,偶遇我大闺蜜 - - episode_done: true eval_labels: - 保存一下 id: lccc text: 期待小猎豹的表现 + x_turn: + id: partner1 + text: 期待小猎豹的表现 + y_turn: + id: partner2 + text: 保存一下 - - episode_done: true eval_labels: - 给你一个么么哒 id: lccc text: 为了你们新年有惊喜,我也是用心良苦了 + x_turn: + id: partner1 + text: 为了你们新年有惊喜,我也是用心良苦了 + y_turn: + id: partner2 + text: 给你一个么么哒 num_episodes: 20000 num_examples: 25558 diff --git a/requirements.txt b/requirements.txt index c0f0f83fa2f..fa72bca2527 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,8 +20,8 @@ joblib==1.2.0 nltk==3.6.6 omegaconf>=2.1.1 pandas==1.4.0 -pytest_regressions==2.1.1 -pytest==5.3.2 +pytest_regressions==2.4.2 +pytest==7.3.0 pexpect==4.7.0 Pillow==9.3.0 py-gfm==1.0.2 @@ -46,7 +46,7 @@ tomli>=2.0.0 torchtext==0.15.1 tornado==6.0.4 tqdm~=4.62.1 -typing-extensions==3.7.4.3 +typing-extensions==4.5.0 Unidecode==1.1.1 urllib3<1.27,>=1.26.5 websocket-client==0.56.0 diff --git a/tests/test_teachers.py b/tests/test_teachers.py index 5a0a5a0e5f6..ffb9464f74b 100644 --- a/tests/test_teachers.py +++ b/tests/test_teachers.py @@ -154,8 +154,9 @@ def test_no_text(self): '{"dialog": [[{"id": "speaker1"}, {"text": "Hello.", "id": "speaker2"}]]}\n' ) opt = {'task': 'jsonfile', 'jsonfile_datapath': fp, 'verbose': True} - with self.assertRaises(AttributeError): - testing_utils.display_data(opt) + + train_out, _, _ = testing_utils.display_data(opt) + self.assertTrue("'text': None" in train_out.split('\n')[1]) def test_firstspeaker_label(self): with testing_utils.tempdir() as tmpdir: @@ -175,7 +176,7 @@ def test_firstspeaker_label(self): l.split(':', 1)[-1].strip() for l in train_out.split('\n') if l in train_out - if 'text' in l + if '[text]' in l ] labels = [ l.split(':', 1)[-1].strip() @@ -204,7 +205,7 @@ def test_secondspeaker_label(self): l.split(':', 1)[-1].strip() for l in train_out.split('\n') if l in train_out - if 'text' in l + if '[text]' in l ] labels = [ l.split(':', 1)[-1].strip() @@ -233,7 +234,7 @@ def test_both_label(self): l.split(':', 1)[-1].strip() for l in train_out.split('\n') if l in train_out - if 'text' in l + if '[text]' in l ] labels = [ l.split(':', 1)[-1].strip()