python—谭松波情感分析

学习目标:

谭松波情感分析

学习内容:

# -*- coding: utf-8 -*-
###唐松波情感分析###
import pandas as pd
import numpy as np

df1=pd.read_excel('E:/pywork\data analysis\谭松波语料/bookneg.xls',header=None, index=None)
print(df1)

data1=np.array(df1[0])
print(len(data1))
print(type(data1))
print(data1.shape)

df2=pd.read_excel('E:/pywork\data analysis\谭松波语料/bookpos.xls',header=None, index=None)
print(df2)
data2=np.array(df2[0])
print(data2)
print(len(data2))

data=np.concatenate((data1, data2), axis=0)
print(len(data))

df3=pd.read_excel('E:/pywork\data analysis\谭松波语料/computerpos.xls',header=None, index=None)
print(df2)
data3=np.array(df3[0])
print(data2)
print(len(data3))
data=np.concatenate((data, data3), axis=0)
print(len(data))


df4=pd.read_excel('E:/pywork\data analysis\谭松波语料/computerneg.xls',header=None, index=None)
print(df2)
data4=np.array(df4[0])
print(data2)
print(len(data4))

data=np.concatenate((data3, data4), axis=0)
print(len(data))
# 
df5=pd.read_excel('E:/pywork\data analysis\谭松波语料/hotelneg.xls',header=None, index=None)
print(df2)
data5=np.array(df5[0])
print(data2)
print(len(data5))

data=np.concatenate((data, data5), axis=0)
print(len(data))

df6=pd.read_excel('E:/pywork\data analysis\谭松波语料/hotelpos.xls',header=None, index=None)
print(df2)
data6=np.array(df6[0])
# print(data2)
print(len(data6))
#
data=np.concatenate((data5, data6), axis=0)
print(len(data))
print(data)

outfile='E:/pywork\data analysis:stopwords.txt'
with open(outfile, 'wb') as f1:
    for i in data:
        out='%s \n' % (i)
        f1.write(out.encode('utf-8'))
with open(outfile,'r',encoding='utf-8') as f:
    lines=f.readlines()
    for i in lines:
        print(i)

你可能感兴趣的:(Python数据分析和数据挖掘,python,机器学习,开发语言)