-
Notifications
You must be signed in to change notification settings - Fork 1
/
bestPersianTofinglish - word input.py
42 lines (33 loc) · 1.31 KB
/
bestPersianTofinglish - word input.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
###############################################################
# PROJECT NAME: persian2finglish #
# SIGN:12148407579314783130754591437669 #
# LICENCED : MIT License #
# CODE BY: MohammadMahdi Barghi #
# Date: 15 MAY 2021 #
# Copyright (c) 2021 mohammad mahdi barghi #
###############################################################
import io
# farsi dataset file
persianFile = io.open("farsi-Words-DATASET.txt", mode="r", encoding="utf-8")
persianWord = persianFile.readlines()
# english dataset file
englishFile = io.open("english-Words-DATASET.txt", mode="r", encoding="utf-8")
englishWord = englishFile.readlines()
for i in range(100):
checkerLine=input("enter persian sentence: ")
res = []
checkertemp = checkerLine.split()
for checker in checkertemp:
flag = False
couter=0
for perWord in persianWord:
couter = couter + 1;
if(perWord.split()==checker.split()):
wait=englishWord[couter-1].rstrip()
res.append(wait)
flag=True
break
if (flag == False):
res.append(checker)
res = ' '.join(res)
print(res)