AICOP高校评分系统

 

该高校评分系统的模型:

 

高校是公办高校,国家教育部直属 比 地方直属的 办学地位和办学资源更高。综合学校 比 专业单一学校办学实力强。工科财经师范等比林业语言等学校在社会的认可度和发挥的价值更大。

给高校一个 基础分,该基础分包含默认的硕士点个数、博士点个数,再考虑主要因素。

 

高校评分是一个综合复杂的系统,该系统只考虑了主要的因素,还有很多特殊的因素未考虑,如学校的特长专业、知名校友等因素。

 

 pasting

#coding=UTF-8

import os
import Tkinter as tk
import tkFont
import string
import tkMessageBox

COLLEAGE_BASE_SCORE = 62

COLLEAGE_BASE_FILE_NAME = 'college_base.txt'
NO_COLLEAGE_BASE_INFO = COLLEAGE_BASE_FILE_NAME+u'中没有该学校的信息。'
COLLEAGE_DESC_TXT_DIR = '.\\college-text\\filter\\'
COLLEAGE_DESC_TXT_EXT = '.txt'
NO_COLLEAGE_DESC_INFO = COLLEAGE_DESC_TXT_DIR+u'中没有该学校的描述信息'

BASE_MASTER_NUM = 80
BASE_DOCTOR_NUM = 10
BASE_POST_DOCTOR_NUM = 2

def CheckColleageSourceInfoExsit(ColleageName):
if False == os.path.exists(COLLEAGE_BASE_FILE_NAME):
return NO_COLLEAGE_BASE_INFO
ColleageDescFile = COLLEAGE_DESC_TXT_DIR + ColleageName + COLLEAGE_DESC_TXT_EXT
if False == os.path.exists(ColleageDescFile):
return NO_COLLEAGE_DESC_INFO
return ''

###########################################################################
# 分析college_base.txt
###########################################################################
def GetColleageInfo(ColleageName):
if False == os.path.exists(COLLEAGE_BASE_FILE_NAME):
return NO_COLLEAGE_BASE_INFO
IsFind = False
ColleageInfoFile = open(COLLEAGE_BASE_FILE_NAME, 'rt')
try:
ColleageInfoLines = ColleageInfoFile.readlines()
for line in ColleageInfoLines:
line = line.decode('utf8', 'ignore')
if string.find(line, ColleageName) != -1:
ColleageInfo = line
IsFind = True
break
finally:
ColleageInfoFile.close()
if IsFind == True:
return ColleageInfo
else:
return ''

def GetColleageScoreByKind(ColleageInfo):
KindsDict = {u'综合': 0.2, u'工科': 0.15, u'医药': 0.1, u'财经': 0.1, u'师范': 0.1,
u'政法': 0, u'农业': 0, u'林业': 0, u'军事': 0, u'民族': 0, u'体育': 0, u'艺术': 0, u'语言': 0}
ColleageInfoList = string.split(ColleageInfo, '\t')
for key in KindsDict.keys():
if key == ColleageInfoList[4]:
return KindsDict[key]
return 0

def GetColleageScoreByLevel(ColleageInfo):
LevelsDict = {u'本科': COLLEAGE_BASE_SCORE, u'高职专科': COLLEAGE_BASE_SCORE, u'独立学院': COLLEAGE_BASE_SCORE, u'其它': COLLEAGE_BASE_SCORE}
ColleageInfoList = string.split(ColleageInfo, '\t')
for key in LevelsDict.keys():
if key == ColleageInfoList[5]:
return LevelsDict[key]
return COLLEAGE_BASE_SCORE

def GetColleageScoreByBelongTo(ColleageInfo):
BelongToDict = {u'教育部': 0.5, u'北京市教育委员会': 0, u'江苏省教育厅': 0, u'上海市教育委员会': 0, u'天津市教育委员会': 0, u'重庆市教育委员会': 0,
u'福建省教育厅': 0, u'广东省教育厅': 0, u'浙江省教育厅': 0, u'山东省教育厅': 0,
u'黑龙江省教育厅': 0, u'四川省教育厅': 0, u'安徽省教育厅': 0,
u'甘肃省教育厅': 0, u'广西壮族自治区教育厅': 0, u'贵州省教育厅': 0, u'海南省教育厅': 0,
u'河北省教育厅': 0, u'河南省教育厅': 0, u'湖北省教育厅': 0, u'湖南省教育厅': 0, u'吉林省教育厅': 0, u'江西省教育厅': 0,
u'辽宁省教育厅': 0, u'内蒙古自治区教育厅': 0, u'宁夏回族自治区教育厅': 0, u'山西省教育厅': 0, u'陕西省教育厅': 0,
u'新疆维吾尔自治区教育厅': 0, u'云南省教育厅': 0, u'中华全国总工会': 0}
ColleageInfoList = string.split(ColleageInfo, '\t')
for key in BelongToDict.keys():
if key == ColleageInfoList[6]:
return BelongToDict[key]
return 0

def GetColleageScoreByIs211(ColleageInfo):
ColleageInfoList = string.split(ColleageInfo, '\t')
if '1' == ColleageInfoList[7]:
return 0.3
else:
return 0

def GetColleageScoreByIs985(ColleageInfo):
ColleageInfoList = string.split(ColleageInfo, '\t')
if '1' == ColleageInfoList[8]:
return 0.3
else:
return 0

def CalcColleageScoreByBaseInfo(ColleageName):
ColleageScore = 0
ColleageInfo = GetColleageInfo(ColleageName)
ColleageInfoList = string.split(ColleageInfo, '\t')
#assert len(ColleageInfoList) == 10
if len(ColleageInfoList) == 10:
ColleageScore1 = GetColleageScoreByKind(ColleageInfo)
ColleageScore2 = GetColleageScoreByLevel(ColleageInfo)
ColleageScore3 = GetColleageScoreByBelongTo(ColleageInfo)
ColleageScore4 = GetColleageScoreByIs211(ColleageInfo)
ColleageScore5 = GetColleageScoreByIs985(ColleageInfo)
ColleageScore = ColleageScore1 + ColleageScore2 + ColleageScore3 + ColleageScore4 + ColleageScore5
else:
ColleageScore = COLLEAGE_BASE_SCORE
#
return ColleageScore

###########################################################################
# 分析txt文件描述
###########################################################################
def IsColleageDescContain(ColleageName, DestColleageDesc):
ColleageDescFile = COLLEAGE_DESC_TXT_DIR + ColleageName + COLLEAGE_DESC_TXT_EXT
if False == os.path.exists(ColleageDescFile):
return False
ColleageInfo = ''
ColleageDescFile = open(ColleageDescFile, 'rt')
try:
ColleageDescLines = ColleageDescFile.readlines()
for line in ColleageDescLines:
line = line.decode('GB2312', 'ignore')
if string.find(line, DestColleageDesc) != -1:
ColleageInfo = line
break
finally:
ColleageDescFile.close()
if string.find(ColleageInfo, DestColleageDesc) != -1:
return True
return False

def GetNumStr(NumDesc):
DescLen = len(NumDesc)
NumStr = ''
for index in range(0, DescLen):
if NumDesc[index] > '0' and NumDesc[index] < '9':
NumStr = NumStr+NumDesc[index]
else:
if len(NumStr) > 0:
break
return NumStr

def GetColleageDoctorMasterNum(ColleageName, DegreeDesc):
DoctorNum = 0
ColleageDescFile = COLLEAGE_DESC_TXT_DIR + ColleageName + COLLEAGE_DESC_TXT_EXT
if False == os.path.exists(ColleageDescFile):
return DoctorNum
IsFind = False
NumStr = ''
ColleageDescFile = open(ColleageDescFile, 'rt')
try:
ColleageDescLines = ColleageDescFile.readlines()
for line in ColleageDescLines:
line = line.decode('GB2312', 'ignore')
if True == IsFind:
NumStr = GetNumStr(line).strip()
if len(NumStr) > 0 :
break
else:
IsFind = False
if string.find(line, DegreeDesc) != -1:
IsFind = True
finally:
ColleageDescFile.close()
if True == IsFind and len(NumStr) > 0:
DoctorNum = string.atoi(NumStr)
if string.find(line, u'一级学科') != -1:
DoctorNum = DoctorNum*4;
return DoctorNum

def GetColleageScoreBy9TopColleage(ColleageName):
if True == IsColleageDescContain(ColleageName, u'九校联盟') or True == IsColleageDescContain(ColleageName, u'C9联盟'):
return 3
else:
return 0

def GetColleageScoreByMountEverestColleage(ColleageName):
if True == IsColleageDescContain(ColleageName, u'珠峰计划'):
return 1.5
else:
return 0

def GetColleageScoreByDoctorAndMasterNum(ColleageName):
MasterNum = GetColleageDoctorMasterNum(ColleageName, u'硕士点')
Score1 = (MasterNum-BASE_MASTER_NUM)/60.0
DoctorNum = GetColleageDoctorMasterNum(ColleageName, u'博士点')
Score2 = (DoctorNum-BASE_DOCTOR_NUM)/40.0
PostDoctorNum = GetColleageDoctorMasterNum(ColleageName, u'博士后流动站')
Score3 = (PostDoctorNum - BASE_POST_DOCTOR_NUM) / 10.0
return Score1+Score2+Score3

def GetColleageScoreBySpecialInfo(ColleageName):
ColleageScore = 0
if True == IsColleageDescContain(ColleageName, u'第一所国立大学'):
ColleageScore = 5
if True == IsColleageDescContain(ColleageName, u'世界一流大学'):
ColleageScore = ColleageScore + 5
if True == IsColleageDescContain(ColleageName, u'诺贝尔奖'):
ColleageScore = ColleageScore + 5
if True == IsColleageDescContain(ColleageName, u'共和国主席'):
ColleageScore = ColleageScore + 5
if True == IsColleageDescContain(ColleageName, u'国家最高教育行政机关'):
ColleageScore = ColleageScore + 5
return ColleageScore

def CalcColleageScoreByTxtInfo(ColleageName):
ColleageScore1 = GetColleageScoreBy9TopColleage(ColleageName)
if 0 == ColleageScore1:
ColleageScore1 = GetColleageScoreByMountEverestColleage(ColleageName)
ColleageScore2 = GetColleageScoreByDoctorAndMasterNum(ColleageName)
ColleageScore3 = GetColleageScoreBySpecialInfo(ColleageName)
return ColleageScore1 + ColleageScore2 + ColleageScore3

###########################################################################
# 窗口
###########################################################################
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
# Set Window Attribute
self.winWidth = 400
self.winHeight = 219
winSizePos = '%dx%d+%d+%d' % (self.winWidth, self.winHeight, (root.winfo_screenwidth()-self.winWidth)/2 , (root.winfo_screenheight()-self.winHeight)/2)
self.master.geometry(winSizePos)
self.master.title("Colleage Scoring")
self.master.resizable(width=False, height=False)
self.grid(sticky=tk.N + tk.S + tk.E + tk.W)
self.createWidgets()

def createWidgets(self):
top = self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
#
self.rowconfigure(0, minsize=30)
self.rowconfigure(1, minsize=40)
self.rowconfigure(2, minsize=20)
self.rowconfigure(3, minsize=40)
self.rowconfigure(4, minsize=10)
self.rowconfigure(5, minsize=30)
self.rowconfigure(6, minsize=8)
self.rowconfigure(7, minsize=30)
self.columnconfigure(0, minsize=15)
self.columnconfigure(1, minsize=80)
self.columnconfigure(2, minsize=200)
self.columnconfigure(3, minsize=80)
#
widgetXorYPad = 6
winFont = tkFont.Font(family='Fixdsys', size=9, weight=tkFont.NORMAL)
self.currColleageName = tk.StringVar()
self.currColleageScore = tk.StringVar()
#
tk.Label(self, text="Colleage:", font=winFont).grid(row=1, column=1, sticky=tk.W, padx=widgetXorYPad)
self.editColleageName = tk.Entry(self, font=winFont, textvariable=self.currColleageName)
self.editColleageName.grid(row=1, column=2, sticky=tk.W + tk.E + tk.N + tk.S, pady=widgetXorYPad)
self.btnCalcCmd = tk.Button(self, text="Calc", font=winFont, fg="blue")
self.btnCalcCmd.grid(row=1, column=3, sticky=tk.E + tk.W, padx=widgetXorYPad)
self.btnCalcCmd.bind('<ButtonRelease-1>', self.CalcCmd)

tk.Label(self, text="Score:").grid(row=3, column=1, sticky=tk.W, padx=widgetXorYPad)
self.editColleageScore = tk.Entry(self, textvariable=self.currColleageScore, font=winFont)
self.editColleageScore.grid(row=3, column=2, sticky=tk.W + tk.E + tk.N + tk.S, pady=widgetXorYPad)

self.btnCalcCmd = tk.Button(self, text="Calc All", font=winFont, fg="blue")
self.btnCalcCmd.grid(row=5, column=2, sticky=tk.E + tk.W, padx=18)
self.btnCalcCmd.bind('<ButtonRelease-1>', self.CalcAllCmd)

self.commentVar = tk.StringVar()
tk.Label(self, textvariable=self.commentVar, wraplength = 200, font=winFont).grid(row=7,column=1,columnspan=3,sticky=tk.N + tk.S + tk.E + tk.W)

def CalcColleageScore(self,ColleageName):
ErrorInfo = CheckColleageSourceInfoExsit(ColleageName)
if len(ErrorInfo) > 0:
return ErrorInfo
else:
ColleageScore1 = CalcColleageScoreByBaseInfo(ColleageName)
ColleageScore2 = CalcColleageScoreByTxtInfo(ColleageName)
ColleageScore = ColleageScore1 + ColleageScore2
if ColleageScore > 100:
ColleageScore = 100
return '%.2f' %ColleageScore

def CalcCmd(self, event):
ColleageName = self.currColleageName.get().strip()
if 0 == len(ColleageName):
return;

self.currColleageScore.set('')
self.commentVar.set('')
self.currColleageScore.set(self.CalcColleageScore(ColleageName))

def CalcAllCmd(self, event):
AllColleageScore = open('college_base_score.txt', 'wt')

IsFirstLine = True
ColleageBaseFile = open('college_base.txt', 'rt')
try:
ColleageBaseLines = ColleageBaseFile.readlines()
for line in ColleageBaseLines:
line = line.decode('utf8', 'ignore')
if True == IsFirstLine:
ScoreInfo = u"系统评分"
IsFirstLine = False
else:
ColleageInfoList = string.split(line, '\t')
ScoreInfo = self.CalcColleageScore(ColleageInfoList[2])
AllColleageScore.write(ScoreInfo.encode('GB2312', 'ignore'))
AllColleageScore.write('\t')
AllColleageScore.write(line.encode('GB2312', 'ignore'))
finally:
ColleageBaseFile.close()

AllColleageScore.close()
self.commentVar.set('所有高校的评分在文件college_base_score.txt的第一列')

root = tk.Tk()
app = Application(root)
app.mainloop()

# if isinstance(ColleageName, unicode):
# tkMessageBox.showinfo('', 'In CalcCmd, unicode')

#AllColleageInfo = open('ColleageScoreCompare.txt', 'wt')
#
#IsFirstLine = True
#ColleageScoreFile = open('college_score.txt', 'rt')
#try:
# ColleageScoreLines = ColleageScoreFile.readlines()
# for line in ColleageScoreLines:
# line = line.decode('utf8', 'ignore')
# if True == IsFirstLine:
# ScoreInfo = u"系统评分"
# IsFirstLine = False
# else:
# ColleageScoreList = string.split(line, '\t')
# ScoreInfo = self.CalcColleageScore(ColleageScoreList[0])
# AllColleageInfo.write(ScoreInfo.encode('GB2312', 'ignore'))
# AllColleageInfo.write('\t')
# AllColleageInfo.write(line.encode('GB2312', 'ignore'))
#finally:
# ColleageScoreFile.close()
#
#AllColleageInfo.close()
pasting

 

posted on 2017-02-05 21:44  Waaaaaall-E  阅读(482)  评论(0编辑  收藏  举报

导航