def test_checkIfCorrectTaggingExistsForAllExamples(self): domsagxo_lexer = eo_lxr.build() # engluento_lexer = en_lxr.WordnetProtoLexer() engluento_lexer = en_lxr.NltkProtoLexer() matches = 0 total_tokens = 0 total_tags = 0 for domsa_prog, englu_prog in paired_programs: domsagxo_lexer.input(domsa_prog.value) domsagxo_tokens = [t for t in domsagxo_lexer] engluento_lexer.input(englu_prog.value) engluento_tokens = [t for t in engluento_lexer] if engluento_tokens[0].value == "to": engluento_tokens = engluento_tokens[1:] total_tokens += len(domsagxo_tokens) # print(domsa_prog.name) # print((len(domsagxo_tokens), len(engluento_tokens))) for eo_token, en_token in zip(domsagxo_tokens, engluento_tokens): # print(str(eo_token.value) + "->" + str(en_token.value) + str(en_token.tags)) # matches += 1 if eo_token.type in [k.value for k in en_token.tags.keys()] else 0 matches += 1 if en_token.tag is not None and eo_token.type == en_token.tag.value else 0 # total_tags += len(en_token.tags.keys()) print(matches) print(total_tokens)
import domsagxo.compilation.esperanto_lexer as lxr lxr.build()
def build_house(clock_type=ClockType.REAL, house_type=HouseType.HOUSE): global ast, smart_home, app lxr.build() ast = ast_bld.build() if clock_type is ClockType.REAL: smart_home = Domsagxo() smart_home.start_scheduler() else: simulative_time = MockClock() scheduler = Horaro(time_function=simulative_time.get_current_time, delay_function=simulative_time.increase_time) smart_home = Domsagxo(scheduler) smart_home.method_dict['haltu'] = smart_home.scheduler.runSetTime smart_home.method_dict['anoncu'] = announce_in_multimedia smart_home.method_dict['atentu'] = receive_input with gui("virtuala domo", showIcon=False) as app: app.addLabel("title", "Welcome to Domsagxo", colspan=2) app.setLabelBg("title", "green") create_clock("horaro", 0, 2) if house_type is HouseType.HOUSE: with app.labelFrame("Enirejo", 1, 2, 1): create_door("antauxa pordo", 0, 0) create_efficient_bulb("enirlumo", 1, 0) with app.labelFrame("Koridoro", 1, 0, 2): create_efficient_bulb("koridora lumo") create_speaker("parolilo", 0, 1) with app.labelFrame("Oficejo", 2, 2, 1, 1): create_efficient_bulb("laborlampo") create_air_conditioner("ofica klimatizilo", 1, 0) with app.labelFrame("Necesejo", 2): create_efficient_bulb("necesa lumo") create_boiler("doma kaldrono", 1, 0) with app.labelFrame("dormcxambro", 2, 1): create_efficient_bulb("dormlumo") else: with app.labelFrame("Koridoro", colspan=2): light_bulbs = [] for i in range(100): light_bulbs += [ create_efficient_bulb(f"{i + 1:03d}", row=int(i / 10), col=(i % 10)) ] smart_home.variables["ampoloj"] = light_bulbs with app.labelFrame("salono", row=2, colspan=2): smart_home.variables["sxambalulo"] = create_efficient_bulb( "sxambalulo") def turn_light_on_if_prime(number): if is_prime(number): smart_home.variables['sxambalulo'].turnOn() else: smart_home.variables['sxambalulo'].turnOff() smart_home.method_dict['cxuprimu'] = turn_light_on_if_prime app.addLabel("l9", "speech:") app.addTextArea("Speech", row=3, column=1, colspan=2) app.addLabel("20", "reply:") app.addLabel("Reply", "Speech", row=4, column=1, colspan=2) app.addButton("Submit", execute_speech, row=5, column=1) app.addButton("Cancel", app.stop, row=5, column=2) app.enableEnter(execute_speech) app.bindKey("<Escape>", app.stop) app.setStopFunction(lambda: True if smart_home.stop_scheduler() else True)
def lexer(self): return eo_lxr.build()