<jupyter_start><jupyter_text>数据清洗1. 删除空评论2. 删除评论中的空格，逗号，波浪线，换行<jupyter_code>df1=data_train.drop(index=(data_train.loc[(data_train["评价内容"].isnull())].index))
df1["评价内容"]=df1["评价内容"].str.replace(" ","").str.replace("，","").str.replace("~","").str.replace("\n","")
df1["分析"]=" "<jupyter_output><empty_output><jupyter_text>用百度AI分析```pythonfrom aip import AipNlp https://cloud.baidu.com/doc/NLP/s/2jwvylmuc%E8%AF%84%E8%AE%BA%E8%A7%82%E7%82%B9%E6%8A%BD%E5%8F%96 百度人工智能SDK示例""" 你的 APPID AK SK """APP_ID = ''API_KEY = ''SECRET_KEY = ''client = AipNlp(APP_ID, API_KEY, SECRET_KEY)text = '味道还行，速度快点就好'""" 如果有可选参数 """options = {}options["type"] = 4""" 带参数调用评论观点抽取 """client.commentTag(text, options)```<jupyter_code>df1["prop"]=""
df1["adj"]=""
df1["sentiment"]=""
import os
for index,row in df1.iterrows():
    try:
        info=client.commentTag(row["评价内容"], options)['items']
        df1.at[index,"分析"]=str(info)
        df1.at[index,"prop"]=str(info[0]["prop"] if info[0] else "")
        df1.at[index,"adj"]=str(info[0]["adj"] if info[0] else "")
        df1.at[index,"sentiment"]=str(info[0]["sentiment"] if info[0] else "")
        !cls 
        os.system('clear')
        print(index/4421,end = "",flush=True)
    except Exception as err:
        print(err)
    except IndexError:
        pass
    time.sleep(0.2)
    pass

# 全部弄好要保存
df1.to_csv(r"C:\Users\admin\Desktop\用户反馈\用户评价分析.csv",index=False,encoding="utf-8")
df1.to_csv(r"C:\Users\admin\Desktop\用户反馈\用户评价分析.csv",index=False,encoding="utf-8")
print(index)
%clear<jupyter_output>
{'fraction_non_alphanumeric': 0.22715404699738903, 'fraction_numerical': 0.03263707571801567, 'mean_word_length': 5.4411764705882355, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '383000', 'license': 'Unlicense', 'n_tokens_mistral': 734, 'n_tokens_neox': 752, 'n_words': 74, 'path': 'jupyter_notebook/HLS-comment.ipynb', 'repo_name': 'crsir007/MyApp', 'size': '1532'}