def _car_brand(doc, cardict): ''' 车辆品牌规整化 ''' src = doc['car_brand'] title = doc['car_title'] brand = doc['car_brand'] tar = u"其它" gc={"series":"","brand":""} if src: if len(src)>20: src=src[:20] src = ''.join(src.split()) src = cardict.washWord(src) if cardict.has_brand(src): gc['brand'] = src return gc values = cardict.findBrandByPinyin(Chinese.pinyin(src)) if values: gc['brand'] = values[0] return gc fenci = segmentRequest(src) gc = guess_car(fenci,cardict) if gc is not None and gc["brand"]!="": if not cardict.has_brand(gc["brand"]): gc['brand']="" return gc return gc
def _car_series(doc,CarDict,): ''' 车辆系列规整化 ''' src = doc['car_series'] title = doc['car_title'] brand = doc['car_brand'] tar = u"其它" gc={"series":"","brand":""} if src is not None and src!='': src = ''.join(src.split()) if len(src)>20: src=src[:20] src = CarDict.washWord(src) if CarDict.has_series(src): gc["series"]= src gc["brand"]=CarDict.get_brand_by_series(src) return gc srcre=src.replace(doc['car_brand'],"").strip() if CarDict.has_series(srcre): gc["series"] = srcre gc["brand"]=CarDict.get_brand_by_series(srcre) return gc # if CarDict.getCarSpecification()['series_synonyms'].has_key(src): # gc['series'] = CarDict.getCarSpecification()['series_synonyms'][src] # gc["brand"]=CarDict.getCarSpecification()['series'][gc['series']]["brand"] # return gc values=CarDict.findSeriesByPinyin(Chinese.pinyin(src)) if values and len(values)>0: gc["series"] = values[0] gc["brand"]=CarDict.get_brand_by_series(values[0]) return gc fenci=segmentRequest(src) gc = guess_car(fenci,CarDict,doc['car_brand']) if gc is not None and gc["brand"]!="": if not CarDict.has_brand(gc["brand"]): gc['brand']="" return gc
def comenzarEjecucionPrograma(self, txtMeditar, txtPosX, txtPosY): button = Button.left self.master.destroy() click_thread = ch.ClickMouse(button, txtMeditar, txtPosX, txtPosY) ch.start(click_thread)
import numpy as np import matplotlib.pyplot as plt import Chinese as ch x = np.linspace(0, 10, 1000) y = np.sin(x) z = np.cos(x**2) plt.figure(figsize=(8, 4)) plt.plot(x, y, label="sin(x)", color="red", linewidth=2) plt.plot(x, z, "b--", label="cos(x^2)") ch.set_ch('ST', 12) plt.xlabel(u"X轴-Time(s)") plt.ylabel(u"Y轴-Volt") ch.set_ch('FS', 20) plt.title(u"中国电建一二•五联合体") plt.ylim(-1.2, 1.2) plt.legend() plt.show()
def Chinese_fenxi(store,now_time_str): sentiment_index = Chinese.Chinese(str(store)) # 调用自定义的中文文本情绪分析模块中的分析函数 write_fenxi(sentiment_index, now_time_str) # 将情绪分析指数同日记提交时间存储 return sentiment_index
import matplotlib.pyplot as plt import pandas as pd from pandas.core.frame import DataFrame import time import Chinese as fnt fnt.set_ch('YH', 12) df_jbcwzb = pd.read_excel('./数据-下载/html-201806-网易-主要财务指标-年度.xlsx') data_reportDate = df_jbcwzb.ix[0, 1:].sort_index(ascending=False) plt.rc('xtick', labelsize=8) plt.rc('ytick', labelsize=8) plt.subplot(311) # 基本每股收益 data_jbmgsy = df_jbcwzb.ix[1, 1:].replace('--', '0').sort_index(ascending=False) plt.plot(data_reportDate, data_jbmgsy.astype(float), label='a') plt.legend() plt.xticks(rotation=90) # plt.xlabel('年报日期') plt.ylabel('每股收益') plt.title('600366-每股收益') plt.subplot(312) # 基本每股收益 data_kfjlr = df_jbcwzb.ix[11, 1:].replace('--', '0').sort_index(ascending=False) plt.plot(data_reportDate, data_kfjlr.astype(float), label='a') plt.legend() plt.xticks(rotation=90)