You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.3 KiB
38 lines
1.3 KiB
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import pandas as pd
|
|
from collections import Counter
|
|
|
|
class DataAnalyzer:
|
|
"""数据分析类"""
|
|
|
|
def __init__(self):
|
|
print("数据分析器初始化")
|
|
|
|
def get_top_applications(self, word_freq, top_n=8):
|
|
"""获取排名前N的AI应用案例"""
|
|
print(f"提取前{top_n}个AI应用案例")
|
|
|
|
# 这里需要根据实际关键词筛选AI应用相关词汇
|
|
# 暂时先返回频率最高的词汇
|
|
top_words = word_freq.most_common(top_n)
|
|
|
|
# 转换为DataFrame便于写入Excel
|
|
df = pd.DataFrame(top_words, columns=['应用案例', '出现次数'])
|
|
return df
|
|
|
|
def save_to_excel(self, df, filename='top_applications.xlsx'):
|
|
"""保存结果到Excel"""
|
|
df.to_excel(filename, index=False)
|
|
print(f"结果已保存到: {filename}")
|
|
|
|
if __name__ == "__main__":
|
|
analyzer = DataAnalyzer()
|
|
test_freq = Counter({
|
|
'智能客服': 45, '代码生成': 38, '文本创作': 35,
|
|
'机器翻译': 32, '智能问答': 28, '数据分析': 25,
|
|
'图像识别': 22, '语音助手': 20, '推荐系统': 18
|
|
})
|
|
top_apps = analyzer.get_top_applications(test_freq)
|
|
print("前8大AI应用案例:")
|
|
print(top_apps) |