Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, sys
- import requests
- def getSet(s):
- cur = s.split('"')
- res = list()
- for i in range(0, len(cur)):
- if (cur[i] == 'name'):
- res.append(cur[i + 2])
- return res
- def changeE(s):
- res = ""
- for i in range(0, len(s)):
- if s[i] == 'ั':
- res += 'ะต'
- else:
- res += s[i]
- return res
- handle = open("input.txt")
- data = handle.read()
- words = data.split(' ')
- url = 'https://sociation.org/ajax/word_associations?word=' + words[0]
- data = {}
- res1 = requests.post(url, json=data).text
- set1 = getSet(res1)
- f = open('output.txt', 'w')
- if words[0] == words[1]:
- for word in set1:
- f.write(changeE(word) + '\n')
- else:
- url = 'https://sociation.org/ajax/word_associations?word=' + words[1]
- data = {}
- res2 = requests.post(url, json=data).text
- set2 = getSet(res2)
- for word in set1:
- if word in set2:
- f.write(changeE(word) + '\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement