# -*- coding: utf-8 -*-
"""voting.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1AIF-ufnNfDKvrpC-7oIhsU-gk_05DpWA
"""

from google.colab import drive
# 將自己的雲端硬碟掛載上去
drive.mount('/content/gdrive')

import pandas as pd
import re
 
#讀取兩個用單個model train public score的最高分數
file1 = pd.read_csv('gdrive/My Drive/hw7/luhuachinese_pretrain_mrc_roberta_wwm_ext_large-0.806.csv') #最好的 0.79233 (model_1)
file2 = pd.read_csv('gdrive/My Drive/hw7/luhuachinese_pretrain_mrc_roberta_wwm_ext_large-0.809.csv') #第二好的 0.79118 (model_2)


ans = []

file1null = file1.isnull()
file2null = file2.isnull()

#如果model_1的結果中有出現空白的題目，就將model_2的結果補進去
for i in range(file1.shape[0]):
    if file1null["Answer"][i] == True and file2null["Answer"][i] == False:
        file1["Answer"][i] = file2["Answer"][i]

#一律把答案中的引號去除掉
for i in range(len(file1['Answer'])):
  file1['Answer'][i] = re.sub(r'「', '', str(file1['Answer'][i]))
  file1['Answer'][i] = re.sub(r'」', '', str(file1['Answer'][i]))

  ans.append(file1['Answer'][i])

with open('result_final_1126.csv', 'w') as f:
    f.write('ID,Answer\n')
    for i in range(len(file1['Answer'])):
        f.write(str(i)+','+str(ans[i]))
        f.write('\n')
# -*- coding: utf-8 -*-
"""voting.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1AIF-ufnNfDKvrpC-7oIhsU-gk_05DpWA
"""

from google.colab import drive
# 將自己的雲端硬碟掛載上去
drive.mount('/content/gdrive')

import pandas as pd
import re
 
#讀取兩個用單個model train public score的最高分數
file1 = pd.read_csv('gdrive/My Drive/hw7/luhuachinese_pretrain_mrc_roberta_wwm_ext_large-0.806.csv') #最好的 0.79233 (model_1)
file2 = pd.read_csv('gdrive/My Drive/hw7/luhuachinese_pretrain_mrc_roberta_wwm_ext_large-0.809.csv') #第二好的 0.79118 (model_2)


ans = []

file1null = file1.isnull()
file2null = file2.isnull()

#如果model_1的結果中有出現空白的題目，就將model_2的結果補進去
for i in range(file1.shape[0]):
    if file1null["Answer"][i] == True and file2null["Answer"][i] == False:
        file1["Answer"][i] = file2["Answer"][i]

#一律把答案中的引號去除掉
for i in range(len(file1['Answer'])):
  file1['Answer'][i] = re.sub(r'「', '', str(file1['Answer'][i]))
  file1['Answer'][i] = re.sub(r'」', '', str(file1['Answer'][i]))

  ans.append(file1['Answer'][i])

with open('result_final_1126.csv', 'w') as f:
    f.write('ID,Answer\n')
    for i in range(len(file1['Answer'])):
        f.write(str(i)+','+str(ans[i]))
        f.write('\n')
# -*- coding: utf-8 -*- voting.ipynb  Automatically generated by Colaboratory.  Original file is located at     https://colab.research.google.com/drive/1AIF-ufnNfDKvrpC-7oIhsU-gk_05DpWA # 將自己的雲端硬碟掛載上去 #讀取兩個用單個model train public score的最高分數 #最好的 0.79233 (model_1) #第二好的 0.79118 (model_2) #如果model_1的結果中有出現空白的題目，就將model_2的結果補進去 #一律把答案中的引號去除掉