Ejemplo n.º 1
0
    def __init__(self):
        self.wordSegmentor = wordSegment()  # 生成 分词器
        self.sentFilter = sentenceFilter()  # 生成 过滤器
        self.NLUModel = NLU()  # 生成 对话理解器
        self.dialogueManager = Manage()  # 生成 对话管理器
        self.Interactor = InteractWithKB()  # 生成 知识交互器
        self.answerGenerator = AnswerGenerator()  # 生成 回答产生器

        self.isFirst = True  # 是一轮对话的开始
        self.isShow = "0"  # 0表示不显示图,1表示显示图
Ejemplo n.º 2
0
def get_files():
    data = request.get_json()
    status = {"status": "Error", "files": [], "msg": "未知错误"}
    status_code = 500
    if data and token_verify(data["token"]):
        status["status"] = "Success"
        status_code = 200
        m = Manage(POST_PATH)
        status["files"] = m.all_file_info()
        del status["msg"]
        return jsonify(status), status_code
    return jsonify(status), status_code
Ejemplo n.º 3
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Budget ver. 1.0", size=(1100, 650))
        self.Centre(wx.BOTH)
        panel = wx.Panel(self, -1)

        notebook = wx.Notebook(panel)
        notebook.AddPage(Expenses(notebook), "Expenses")
        notebook.AddPage(Income(notebook), "Income")
        notebook.AddPage(Transfer(notebook), "Transfer")
        notebook.AddPage(Accounts(notebook), "Accounts")
        notebook.AddPage(Analysis(notebook), "Analysis")
        notebook.AddPage(Manage(notebook), "Manage")

        sizer = wx.BoxSizer()
        sizer.Add(notebook, 1, wx.EXPAND)
        panel.SetSizer(sizer)
Ejemplo n.º 4
0
def delete():
    data = request.get_json()
    status = {"status": "Error", "msg": "未知错误"}
    status_code = 500
    if data is None:
        status["msg"] = "参数错误"
        status_code = 400
    elif {"token", "filename"}.difference(set(data.keys())):
        status["msg"] = "缺少以下参数:{}".format(", ".join({"token", "filename"}.difference(set(data.keys()))))
        status_code = 400
    elif not token_verify(data["token"]):
        status["msg"] = "无效token"
        status_code = 401
    else:
        m = Manage(POST_PATH)
        s, msg = m.del_file(filename=data["filename"], local_git_path=LOCAL_GIT_PATH)
        threading.Thread(target=deploy, args=[]).start()
        if s:
            status["status"] = "Success"
            status["msg"] = msg
            status_code = 200
    logger.info(status["msg"])
    return jsonify(status), status_code
Ejemplo n.º 5
0
# -*- encoding:gbk -*-
from process.video_process import VideoProcess
from process.image_process import ImageProcess
from model.face_recognize_easy import EasyDist
from model.face_recognize_sgd import SgdDist
import numpy,os,json,time
from multiprocessing import Process,Manager,Lock,Pool,freeze_support
from manage import Manage
from conf import *
ServerManage = Manage(file_config,sql_config)
global Model,Ip,Vp

hist = compute_config["hist"]
process_num = compute_config["process_num"]
Model = SgdDist(model_config["recognize_model_path"])
Ip = ImageProcess(
    face_detect_filename=model_config["face_detect_path"],
    face_vec_filename=model_config["face_vec_path"]
)
Vp = VideoProcess(model_config["ffmpge_path"])
url = "%s:%d"%(app_config["host"],app_config["port"]) +"/imgs/result?t=%s&hist=%s&videoname=%s"



def get_feature_spark(imgs_path,hist,feature_path):
    command = "spark-submit %s %s %s %s"%(model_config["spark_model_path"],
                                          imgs_path,
                                          hist,
                                          feature_path
                                          )
    os.popen(command)
Ejemplo n.º 6
0
from flask import Flask, render_template
import data
from manage import Manage

manage = Manage()

app = Flask(__name__)


@app.context_processor
def inject_stage_and_region():
    return dict(departures=data.departures)


@app.route('/')
@app.route('/index')
def index():
    return render_template('index.html', tours=data.tours)


@app.route('/from/<direction>')
def direction(direction):
    return render_template('direction.html',
                           departure=manage.depart_city(direction),
                           direction=direction)


@app.route('/tour/<id>')
def tour(id):
    return render_template('tour.html', tour=data.tours.get(int(id)))
Ejemplo n.º 7
0
def main():
    try:
        manage = Manage()
        manage.start()
    except Exception as e:
        print('pool run error.', e)
Ejemplo n.º 8
0
'''main mario file'''
import os
from polymorph import POLY
from board import BOARD
from scene import Scene
from person import PERSON, CHECKPOINT
from manage import Manage

SCENE = Scene()
M = Manage()
i = 0
MID = 0
TIMER = 0
os.system('aplay -q ./mario-theme.wav&')
while i <= BOARD.width - 80:
    if PERSON.xpos == 25 and PERSON.ypos == 504:
        break
    os.system("clear")
    M.printhead()
    SCENE.make_cm(i)
    SCENE.make_pps()
    SCENE.brick_coin()
    SCENE.moving_bar()
    SCENE.make_flag()
    i = SCENE.enemy(i)
    # PERSON.print_mario(PERSON.xpos,PERSON.ypos)
    POLY.print_poly(PERSON, PERSON.xpos, PERSON.ypos)
    # BOARD.print_board(i,i+80)
    POLY.print_poly(BOARD, i, i + 80)
    # PERSON.move(i)
    POLY.move_poly(PERSON, i)
Ejemplo n.º 9
0
from deportament import Deportament
from manage import Manage
from person import Person

bob = Person('Bob Smit', 'dev', 3000)
lot = Person('Lot Smit', 'dev', 3000)
gut = Manage('Gut Smit', 300)

develop = Deportament(bob, lot, gut)

import shelve

db = shelve.open('Person_Develop')

for obj in bob, lot, gut:
    db[obj.name] = obj

db.close()

if __name__ == "__main__":
    db = shelve.open('Person_Develop')

    print(db['Bob Smit'])

    def vglub(element, count=3):

        print('.' * count, element)
        count += 3
        for key in element.__bases__:
            vglub(key, count)
Ejemplo n.º 10
0
''' The run file
# Instances of classes created here
# for running the application.'''

import os
from bomberman import Bomberman
from manage import Manage

# TEST is an object of Bomberman
TEST = Bomberman()

# TEST1 is an object of Manage
TEST1 = Manage()

# the initial Welcome Print.
print("")
print("Welcome, to this rendition of Bomberman!")
print("")
print("Press 'Enter' to start playing.")
TAKENINPUT = input()

# This generates bricks on the board
TEST.generatebricks()
# This generates enemies on the board
TEST.generateenemies()
# This generates the bomberman
TEST.generatebomberman()

i = 0
while True:
    os.system("tput reset")
Ejemplo n.º 11
0
def main():
    
    wordSegmentor = wordSegment() # 生成 分词器
    sentFilter = sentenceFilter()  # 生成 过滤器
    NLUModel = NLU()        # 生成 对话理解器
    dialogueManager = Manage()  # 生成 对话管理器
    Interactor = InteractWithKB()  # 生成 知识交互器
    answerGenerator = AnswerGenerator()  # 生成 回答产生器

    # input_x = "刘通是谁的学生"
    # input_x = "介绍一下邓华老师"
    # input_x = "邓华老师的研究方向是什么"
    input_x = "介绍一下机电工程学院"
    i = 0
    # data = loadFile()
    
    print()
    print("输入的句子是",input_x)

    sentCuted = wordSegmentor.cut_sentence(input_x)
    # sentFilter.filtSent(sentCuted)  # 先不加过滤器
    # try:

    if wordSegmentor.hasSentence == True:  # 保证有内容
        if True == True:  # 保证是任务相关的句子
            i+=1
            print("这是第",i,"句话")
        # input_x = "王老师的办公室在哪"
        # input_x = "王恒升老师的办公室在哪"

        # intent = "query_location"
        # slot = ["first_name","teacher","o","room","o","o"]
        # slot = ["name","teacher","o","room","o","o"]

        # sentence = ["王","老师","的","办公室","在","哪里"]
        # sentence = ["王恒升","老师","的","办公室","在","哪里"]

            # sentFilter.filtSent(sentCuted)
            # print("sentCuted",sentCuted)
            sentence,intent,slot = NLUModel.nluSentence(sentCuted)
            print("intent = ",intent)

            strCode = dialogueManager.firstmanage(intent,slot,sentence)
            # print("strCode",strCode)
            for _ in range(5):
                if dialogueManager.state == 2:  # 只有是完成状态才会产生答案
                    print("-----单轮对话----")
                    # print("strCode",strCode)
                    print("sentence",sentence)
                    print("dialogueManager.intentHold",dialogueManager.intentHold)
                    print("dialogueManager.slotStrHold",dialogueManager.slotStrHold)
                    print("dialogueManager.slotDictHold",dialogueManager.slotDictHold)

                    ans = Interactor.information_to_answer(sentence,
                                                            dialogueManager.intentHold,
                                                            dialogueManager.slotStrHold,
                                                            dialogueManager.slotDictHold)
                    # print("myManager.state",dialogueManager.state)
                    # print("Interactor.interactState",Interactor.interactState)
                    print("ans",ans)
                    input_x = dialogueManager.newSentence()
                    print("newSentence",input_x)
                    answerSentence = answerGenerator.generateAnswer(input_x,ans,intent,dialogueManager.answerState)
                    print("answerSentence",answerSentence)
                    print("----- 单轮结束-------")
                    print()

                elif dialogueManager.state == 1: # 开启多轮对话
                    print("----开启多轮对话----")
                    querySentence = dialogueManager.querySentence(intent,strCode)  # 产生问句
                    print("querySentence",querySentence)

                elif dialogueManager.state == 3: # 处于多轮对话中
                    print("-----处于多轮对话中-----")
                    # intent_new = "query_location"
                    # slot_new = ["name"]
                    # sentence_new = ["王恒升"]
                    # input_x = "询问一个老师的办公室"
                    input_x = input("请输入句子:--- ")
                    print("dialogueManager.slotStrHold",dialogueManager.slotStrHold)
                    sentCuted = wordSegmentor.cut_sentence(input_x)
                    sentence_new,intent_new,slot_new = NLUModel.nluSentence(sentCuted)
                    print("intent_new",intent_new)

                    dialogueManager.informationFuse(dialogueManager.intentHold,slot_new,sentence_new)  # 将新旧信息融合
                    # strCode = dialogueManager.calState(intent,dialogueManager.slotStrHold)
                    dialogueManager.str2State(dialogueManager.intentHold,dialogueManager.slotStrHold) # 确定对话管理器状态
                    dialogueManager.buildSlotDict(dialogueManager.intentHold,slot_new,sentence_new)

                    print("ialogueManager.state==3",dialogueManager.state)
                    # 不一定产生问句啊,有可能是完成状态,就不需要产生问句了
                    if dialogueManager.state==3:
                        print("sentence_new333 ",sentence_new)
                        print("dialogueManager.slotStrHold333 ",dialogueManager.slotStrHold)
                        querySentence = dialogueManager.querySentence(dialogueManager.intentHold,dialogueManager.slotStrHold)  # 产生问句
                        print("querySentence333 ",querySentence)

                    print("---------多轮对话中(结束)---------------------------------")
        else:
            print("您的请求不在本系统支持范围内")
                
        
    else:
        print("请输入内容")
Ejemplo n.º 12
0
def rebuild():
    manage = Manage(app)
    manage.reset_local_persistence()
    manage.build_clean_persistence()
    manage.populate_persistence()
Ejemplo n.º 13
0
import click
from flask import Flask
import random

import utils
import models
import actions

from manage import Manage

import logging
from datetime import datetime

app = Flask(__name__)
manage = Manage(app)
if not manage.check_persistence_exists():
    manage.build_clean_persistence()
    manage.populate_persistence()

### NON OPEN ACTIVE BOOKING API ENDPOINT ###


@app.route("/", methods=["GET"])
def index():
    return utils.error_response('nothing_to_see_here')


### OPEN ACTIVE BOOKING API ENDPOINTS ###

### GET functions ###
Ejemplo n.º 14
0
 def __init__(self):
     super().__init__()
      
     self.initUI()
     self.manage=Manage()
Ejemplo n.º 15
0
from manage import Manage
from person import Person


class Deportament:
    def __init__(self, *args):
        self.args = args

    def showAll(self):
        for obj in self.args:
            print(obj)

    def giveRaise(self, procent):
        for obj in self.args:
            obj.giveraise(procent)


if __name__ == "__main__":

    d1 = Person('Nikita Didenko', 'Developers', 3000)
    d2 = Person('Andrey Didenko', 'Developers', 300)
    d3 = Person('Elena Didenko', 'Developers', 200)
    d4 = Manage('Katy Didenko', 100)
    my_Family = Deportament(d1, d2, d3, d4)
    my_Family.giveRaise(10)
    my_Family.showAll()
Ejemplo n.º 16
0
'''   The Bomb Class

 The bomb class does not inherit
 any other class, it creates a bomb,
 keeps count of bombs and their positions,
 explosion, and then clears that explosion.
'''

from check import checkboard
from board import Board
from enemy import Enemy
from manage import Manage

#   An instance of manage to keep
#   count of time, score and lives.
MANAGEINSTANCE = Manage()


class Bomb:
    '''Bomb class has all bomb functions.'''
    # Arrays for x,y coordinates of Bombs
    Bomba = []
    Bombb = []

    # the explosion function to explode bombs.
    # Dealt individually for 4 positions around a coordinate.
    def explosion(self, alpha, beta):
        '''Deals with explosion of bomb'''
        # For the oroginal position.
        for j in range(0, 4):
            Board.board[(beta + 1) * 2][(alpha + 1) * 4 + j] = 'e'