forked from Vyxal/Vyxal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwords.py
37 lines (31 loc) · 872 Bytes
/
words.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
import dictionary
def extract_word(code):
import encoding
import utilities
index_pos = utilities.to_ten(code, encoding.compression)
return _words[index_pos]
def word_index(word):
import utilities
import encoding
if word in _words:
ret = utilities.from_ten(_words.index(word), encoding.compression)
if len(ret) == 1:
ret = "λ" + ret
return ret
else:
return -1
_words = dictionary.contents
if __name__ == "__main__":
while 1:
x = input()
if " " in x:
output = ""
words = x.split(" ")
for word in words:
if word_index(word) != -1:
output += word_index(word) + " "
else:
output += word + " "
print(output)
else:
print(word_index(x))