Spaces:
Sleeping
Sleeping
| from wisdom_extract import allam | |
| import garood | |
| from concurrent.futures import ThreadPoolExecutor, as_completed | |
| _log_file = None | |
| def print(txt=""): | |
| global _log_file | |
| if _log_file is None: | |
| _log_file = open("complete.tmp", "w") | |
| _log_file.write(f"{txt}\n") | |
| _log_file.flush() | |
| def suggest(input): | |
| resp = allam("allam/akmil.txt", {"input": input}) | |
| poss = [] | |
| for line in resp.split("\n"): | |
| if not line.startswith("- "): continue | |
| verse = line[2:].strip() | |
| if len(verse) <= len(input): continue | |
| poss.append(verse) | |
| return poss | |
| def shakkil(p): | |
| return allam("allam/shakl.txt", {"input": p}).strip() | |
| def gen(input): | |
| print("SUGGESTING...") | |
| poss = set() | |
| with ThreadPoolExecutor(max_workers=16) as executor: | |
| futures = [ | |
| executor.submit(suggest, input) | |
| for _ in range(5) | |
| ] | |
| for future in as_completed(futures): | |
| for p in future.result(): poss.add(p) | |
| print("\n".join(poss)) | |
| return poss | |
| def shakk(poss): | |
| print("TASHKEELING...") | |
| pshak = [] | |
| with ThreadPoolExecutor(max_workers=16) as executor: | |
| futures = [ | |
| executor.submit(shakkil, p) | |
| for p in poss | |
| ] | |
| for future in as_completed(futures): | |
| pshak.append(future.result()) | |
| print("\n".join(pshak)) | |
| return pshak | |
| def filter(pshak): | |
| print(f"EVALUATING...") | |
| BH = garood.config()['bahr']['kamil_1'] | |
| for p in pshak: | |
| EN, HR = garood.en_gen_enhr(garood.ar_gen_en(p)) | |
| c, s = garood.bh_gen_best(BH, EN, HR, True) | |
| g = garood.state_to_str(s, EN) | |
| if c >= 0: yield (c, p, s, g) | |
| if __name__ == "__main__": | |
| pshak =\ | |
| """ | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุฏูุงุฑูุฉู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุญูุจูู ุงููููุจูู | |
| ูููู ุณูุงู ูุฑ ุงููุฃูุตูุญูุงุจู ููู ููููู ู ูุนููููู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ู ูุญููููู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุฑูู ููู ุฏูุงุฑูุณูุ | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููููู ู ูุฑูุชูุนู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ู ูุฏูุญู ุงููููุจูููู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููุดูุฑู ุงููููุถูุง | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ู ูุฏูุญู ุงููุนูููุง | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุงููููุงุฏูู ุงูุฑููุทูุจูุ | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููุงุฏูู ุงููุนูููู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุฌูุจููู ุตูุนูุจูุ | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ู ูุฌูููุณู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุฃูุฑูุถู ุงูุณููู ูุง | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููุงุฏูู ุงููุญููููุ | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุณูููุญู ุงูุซููุฑูู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููุงุฏููู ุงููููููุง | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุฎูููุฑู ู ูุดูููุฏู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ู ูุฏูุญู ุงููููุฑููู ู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ู ูุฏูู ุงููููุฑููู ู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุฏูุนูุฉู ููุฑูุงุญูุฉู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููุงุฏูู ุงูุฑููุจูู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููููู ู ูุดูุฑููู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ุญูููููู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููููู ู ูููููุนู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููููู ู ูููุชูุฌูุนู | |
| ูููู ุณูุงู ูุฑู ุงููุฃูุตูุญูุงุจู ููู ููููู ู ูููุณูู ู | |
| """.strip().split("\n") | |
| input = "ูุฏ ุณุงู ุฑ ุงูุฃุตุญุงุจ ูู" | |
| poss = gen(input) | |
| pshak = shakk(poss) | |
| for p, c, s, g in filter(pshak): | |
| print(p) | |