-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
94 lines (87 loc) · 2.75 KB
/
index.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const axios = require("axios");
module.exports = async function (word, uri = "https://sozluk.gov.tr/") {
const datas = {
word: null,
lisan: null,
means: null,
compounds: null,
proverbs: [],
compilation: [],
glossaryOfScienceAndArtTerms: [],
westOpposite: [],
guide: [],
etymological: [],
};
try {
/* Güncel Türkçe Sözlük */
const { data } = await axios(
`${uri}gts?ara=` + encodeURI(word.toLocaleLowerCase("tr"))
);
if (data.error) {
datas.word = null;
datas.lisan = null;
datas.means = null;
datas.examples = null;
datas.compounds = null;
}
const [result] = data;
if (!result) {
datas.word = null;
datas.lisan = null;
datas.means = null;
datas.examples = null;
datas.compounds = null;
}
const { anlamlarListe, birlesikler, lisan = null } = result;
const means = anlamlarListe;
const compounds = birlesikler?.split(", ") || [];
datas.word = result?.madde || datas.word;
datas.lisan = lisan;
datas.means = means || datas.means;
datas.compounds = compounds || datas.compounds;
/* Atasözleri ve Deyimler Sözlüğü */
const atasozu = await axios(
`${uri}atasozu?ara=` + encodeURI(word.toLocaleLowerCase("tr"))
);
if (atasozu.data.error) {
datas.proverbs = null;
} else datas.proverbs = atasozu.data;
/* Derleme Sözlüğü */
const derleme = await axios(
`${uri}derleme?ara=` + encodeURI(word.toLocaleLowerCase("tr"))
);
if (derleme.data.error) {
datas.compilation = null;
} else datas.compilation = derleme.data;
/* Bilim ve Sanat Terimleri Sözlüğü */
const eser_ad = await axios(
`${uri}terim?eser_ad=t%C3%BCm%C3%BC&ara=` +
encodeURI(word.toLocaleLowerCase("tr"))
);
if (eser_ad.data.error) {
datas.glossaryOfScienceAndArtTerms = null;
} else datas.glossaryOfScienceAndArtTerms = eser_ad.data;
/* Türkçede Batı Kökenli Kelimeler Sözlüğü */
const bati = await axios(
`${uri}bati?ara=` + encodeURI(word.toLocaleLowerCase("tr"))
);
if (bati.data.error) {
datas.westOpposite = null;
} else datas.westOpposite = bati.data;
/* Yabancı Sözlere Karşılıklar Kılavuzu */
const kilavuz = await axios(
`${uri}kilavuz?prm=ysk&ara=` + encodeURI(word.toLocaleLowerCase("tr"))
);
if (kilavuz.data.error) {
datas.guide = null;
} else datas.guide = kilavuz.data;
/* Eren Türk Dilinin Etimolojik Sözlüğü */
const etms = await axios(
`${uri}etms?ara=` + encodeURI(word.toLocaleLowerCase("tr"))
);
if (etms.data.error) {
datas.etymological = null;
} else datas.etymological = etms.data;
return datas;
} catch (error) {}
};