def __init__(self): Controller.__init__(self) texts = '' for path in constants.PROCESSED_SPEECHES_PATHS: with open(path, 'r') as corpus: texts += re.sub(pattern='\n+', repl='\n\n', string=corpus.read().lower()).strip() + '\n\n' self.mcc_speech_generator = MccSpeechGenerator().preprocess(texts)
def run(): texture = FuzzyDescription() capacity = FuzzyDescription() cycle_type = FuzzyDescription() rules = [] texture.add_region('very soft', trap_region(-10, 0.0, 0.4, 0.8)) texture.add_region('soft', tri_region(0.4, 0.8, 1.2)) texture.add_region('normal', tri_region(0.5, 1.0, 1.5)) texture.add_region('resistant', trap_region(0.9, 1.1, 1.2, 10)) capacity.add_region('small', trap_region(-1500, 0, 1, 2)) capacity.add_region('medium', tri_region(1, 4.5, 8)) capacity.add_region('high', trap_region(5, 6, 7, 1500)) cycle_type.add_region('delicate', trap_region(-150, 0, 0.4, 0.8), inverse_line(0.8, 0.4)) cycle_type.add_region('easy', tri_region(0.5, 0.7, 1.0), inverse_tri(0.5, 0.7, 1.0)) cycle_type.add_region('normal', tri_region(0.6, 0.7, 1.1), inverse_tri(0.6, 0.7, 1.1)) cycle_type.add_region('intense', trap_region(1.2, 1.4, 1.5, 1500), inverse_line(1.2, 1.4)) rules.append(FuzzyRule({'texture': 'very soft', 'capacity': 'small'}, {'cycle_type': 'delicate'})) rules.append(FuzzyRule({'texture': 'soft', 'capacity': 'small'}, {'cycle_type': 'easy'})) rules.append(FuzzyRule({'texture': 'normal', 'capacity': 'small'}, {'cycle_type': 'easy'})) rules.append(FuzzyRule({'texture': 'resistant', 'capacity': 'small'}, {'cycle_type': 'easy'})) rules.append(FuzzyRule({'texture': 'very soft', 'capacity': 'medium'}, {'cycle_type': 'easy'})) rules.append(FuzzyRule({'texture': 'soft', 'capacity': 'medium'}, {'cycle_type': 'normal'})) rules.append(FuzzyRule({'texture': 'normal', 'capacity': 'medium'}, {'cycle_type': 'normal'})) rules.append(FuzzyRule({'texture': 'resistant', 'capacity': 'medium'}, {'cycle_type': 'normal'})) rules.append(FuzzyRule({'texture': 'very soft', 'capacity': 'high'}, {'cycle_type': 'normal'})) rules.append(FuzzyRule({'texture': 'soft', 'capacity': 'high'}, {'cycle_type': 'normal'})) rules.append(FuzzyRule({'texture': 'normal', 'capacity': 'high'}, {'cycle_type': 'intense'})) rules.append(FuzzyRule({'texture': 'resistant', 'capacity': 'high'}, {'cycle_type': 'intense'})) controller = Controller(texture, capacity, cycle_type, rules) print(controller.compute({'capacity': 7, 'texture': 0.5})) print(controller.compute({'capacity': 3, 'texture': 0.8})) print(controller.compute({'capacity': 1, 'texture': 0.4})) print(controller.compute({'capacity': 7, 'texture': 0.3}))
class Application: """ 起動アプリケーションクラス """ def __init__(self): #コマンド引数 self.argument = Argument() #コントローラ self.ctrl = Controller() def run(self): target = self.argument.getTarget() #引数により実行メソッドを切り替え if target == "tokoyami": self.ctrl.tokoyami() else: pass
def __init__(self): Controller.__init__(self) self._qr = QueryResponder() with open(constants.PROCESSED_QNA_PATH) as f: qna_list = pickle.load(f) with open(constants.PROCESSED_QUOTES_PATH) as f: text = f.read().lower().decode('utf-8').strip() with open(constants.PROCESSED_FB_POSTS_PATH) as f: text = text + '\n\n' + f.read().lower().decode('utf-8').strip() for path in constants.PROCESSED_SPEECHES_PATHS: with open(path, 'r') as corpus: text += re.sub( pattern='\n+', repl='\n\n', string=corpus.read().lower( )).decode('utf-8').strip() + '\n\n' tokenizer = nltk.data.load('tokenizers/punkt/english.pickle') sentences = tokenizer.tokenize(text) if not os.path.exists(constants.CHAT_INFERSENT_MODEL_PATH): self._engine = self._qr.preprocess(qna_list, sentences)
def __init__(self): Controller.__init__(self) self._api = tweeter_utils.TweeterUtils() os.chdir(DEEP_BB_PREFIX_PATH) with open(constants.PROCESSED_TWEETS_PATH, 'r') as corpus: tweets_text = re.sub(pattern='\n+', repl='\n', string=corpus.read().lower()) with open(constants.PROCESSED_QUOTES_PATH, 'r') as corpus: quotes_text = re.sub(pattern='\n+', repl='\n', string=corpus.read().lower()) with open(constants.PROCESSED_FB_POSTS_PATH, 'r') as corpus: fb_text = re.sub(pattern='.', repl='.\n', string=re.sub(pattern='\n+', repl='\n', string=corpus.read().lower())) self.mcc_tweets_generator = MccTweetGenerator().preprocess( [tweets_text, fb_text, quotes_text], weights=[0.4, 2, 1])
from flask import Blueprint, render_template, jsonify, request from controllers.Controller import Controller from models.Coordinates import CoordinatesModel from models.Stores import StoreModel blueprint = Blueprint('stores_blueprint', __name__, template_folder='../templates') # Create all our models to pass to their controllers. store_model = StoreModel() coordinates_model = CoordinatesModel() # Create all the controllers we need. Pass them the requires models. controller = Controller(store_model=store_model, coordinate_model=coordinates_model) # this endpoint returns json rendered as html @blueprint.route('/') def render_stores_page(): page_data = get_data() return render_template('stores.html', store_list=page_data) # this endpoint returns raw json of all the postcodes @blueprint.route('/data') def render_data(): return jsonify(get_data())
def __init__(self, server): Controller.__init__(self, server)
def __init__(self, game_map, pos): Unit.__init__(self, game_map, Controller(), Constants.core_hp, pos, Constants.core_width, Constants.core_height, "player", "core", UnitTypes.core)
def setUp(self): self.gui = Gui() self.bookdao = BookDAO('test.db') self.controller = Controller(self.bookdao, self.gui) self.book = Book("alpha", "beta", "22-2-2022", "32432")
import multiprocessing from views.Gui import Gui from models.BookDAO import BookDAO from models.Book import Book from controllers.Controller import Controller if __name__ == "__main__": gui = Gui() bookDAO = BookDAO('main.db') #bookDAO.add_book(Book('title1', 'author1', 'year1', '1')) #bookDAO.add_book(Book('title2', 'author2', 'year2', '2')) #bookDAO.add_book(Book('title3', 'author3', 'year3', '3')) controller = Controller(bookDAO, gui) gui.add_gui_listener(controller) controller.start() #row = ("kostas", "kostas_ait", "17/05/1973", "12312") #db.insert_row(*row) # db.view_all() #process1 = multiprocessing.Process(target=Gui) # process2 = multiprocessing.Process(target = Gui) #process1.start() # process2.start() #process1.join() # process2.join()
def __init__(self, game_map, pos): Building.__init__(self, game_map, Controller(), 10, pos, 30, 30, "wall", UnitTypes.wall, 1)
def __init__(self): #コマンド引数 self.argument = Argument() #コントローラ self.ctrl = Controller()