示例#1
0
def usersupdate():
    if request.method=="POST":
        info=request.form.get('password')
        id=request.form.get("id")
        print  id,info
        result=readfile()
        i=onedata(result,id)
        result[i]['password']=info
        writefile(result)
        return redirect("/users/")
    else:
        id=request.args.get("id")
        result=readfile()
        i=onedata(result,id)
        #print result[i],i,id
        return  render_template('user_update.html',info=result[i])
示例#2
0
def usersdelete():
    id=request.args.get("id")
    result=readfile()
    #print result
    i=onedata(result,id)
    del  result[i]
    writefile(result)
    return  redirect('/users/')
示例#3
0
def login():
    if request.method =="GET":
        return  render_template('login.html')
    else:
        username=request.form.get('username')
        password=request.form.get('password')
        result=readfile()
        print result,username,password
        for i in result:
            if i.get('name')==username and  i.get('password')==password:
                print "登录成功!"
                return redirect('/users/')
        return render_template('login.html',error="username or password error")
示例#4
0
def  useradd():
    if request.method =="GET":
        return   render_template('user_create.html')
    else:
        readresult=readfile()
        LEN=max([i['id'] for  i in readresult])
        userinfo=request.form
        result={k:v[0] for k,v in dict(userinfo).items()}
        value=checkuser(result['name'])
        if value==1:
            return   render_template('user_create.html',error='user existence')
        else:
            result['id']=LEN+1
            readresult.append(result)
            print readresult
            writefile(readresult)
            return redirect('/users/')
示例#5
0
import Similar
import rwfile
import datetime
import nlptest

nowTime1 = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')  # 现在
print(nowTime1)
sentencelist = rwfile.readfile("vbd0701.txt", "vbc0701.txt", "ta0701.txt",
                               "txt2/")
print(sentencelist)
print(len(sentencelist))

dname = "txt/50d.txt"

posResult = []

posResult = nlptest.deal(sentencelist)
print(posResult)

resulSet1 = []
resulSet2 = []
resulSet3 = []
resulSet4 = []

index = 0
for i in range(len(sentencelist)):
    if (posResult[index] == 1):
        resulSet1.append(sentencelist[index])
        index += 1
        continue
    elif (posResult[index] == 2):
示例#6
0
import rwfile
import simhash

sentenlist = rwfile.readfile()
# print(sentenlist)

sentenlist2 = rwfile.readfile2("command4.txt")
# print(sentenlist2)

L2 = []
for i in sentenlist2:
    L1 = []
    for j in sentenlist:
        L1.append(simhash.run_simhash(i, j))
    L2.append(L1)
# print(L2)
for i in L2:
    print(i)

MinList = []
for i in L2:
    Min = min(i)
    index = 0
    for j in i:
        if j == Min:
            MinList.append(index)
            break
        index += 1
print(len(MinList))
print(MinList)
示例#7
0
def users():
    result=readfile()
    return  render_template('users.html',users=result)
示例#8
0
    curLine = line.strip().split(" ")
    vecs.append(curLine[:])
v1 = Similar.calculate("50d.txt", sentence1).tolist()
# print(v1)
result = []
for i in vecs:
    c = list(map(float, i))
    result.append(Similar.cos_sim(v1, c))

print(result)
max = result[0]
count = 0
rank = []
rank.append(1)
for i in result:
    count = count + 1
    if i > max:
        max = i
        f = count
        rank.append(f)
    else:
        continue
print(f)
print(rank[-3:])

sentenceList = rwfile.readfile()
for i in rank[-3:]:
    print(sentenceList[i])
    # print(c)
    # print(curLine)