forked from victoriasovereigne/tesaurus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tesaurus.py
39 lines (32 loc) · 1.03 KB
/
tesaurus.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
# ==================================================
# Written in March 2016 by Victoria Anugrah Lestari
# ==================================================
import json
# ==================================================
# Membaca dictionary dari json
# ==================================================
def load(filename):
with open(filename) as data_file:
data = json.load(data_file)
return data
# load dictionary
mydict = load('dict.json')
# ==================================================
# Mencari sinonim suatu kata
# ==================================================
def getSinonim(word):
if word in mydict.keys():
return mydict[word]['sinonim']
else:
return []
# ==================================================
# Mencari antonim suatu kata
# ==================================================
def getAntonim(word):
if word in mydict.keys():
if 'antonim' in mydict[word].keys():
return mydict[word]['antonim']
return []
print getSinonim('senang')
print getSinonim(getAntonim('senang')[0])
print getSinonim('anna')