Code
import discord
import wikipedia
from difflib import SequenceMatcher
import wikipediaapi
def suggestKeyword(Keyword):
result = wikipedia.search(Keyword, results = 10)
if len(result) > 0:
precent = [SequenceMatcher(None,Keyword.lower(),result[x].lower()).ratio() for x in range(len(result))]
sgt = ""
ratio = 0.0
for x in range(len(precent)):
if precent[x] > ratio and result[x].lower() != Keyword.lower():
ratio = precent[x]
sgt = result[x]
return sgt
else:
return "None"
def listSuggest(Keyword):
return wikipedia.search(Keyword, results = 10)
def summary(Keyword):
result = wikipedia.search(Keyword, results = 10)
precent = [SequenceMatcher(None,Keyword.lower(),result[x].lower()).ratio() for x in range(len(result))]
wiki_wiki = wikipediaapi.Wikipedia('en')
page = wiki_wiki.page(result[precent.index(max(precent))])
string = page.summary
n = 2000
return [string[i:i+n] for i in range(0, len(string), n)]
client = discord.Client()
@client.event
async def on_ready():
print("Successfully connected")
@client.event
async def on_message(message):
if message.content.startswith("suggest of keyword"):
k = message.content.split("suggest of keyword ")[1]
await message.channel.send(suggestKeyword(k))
elif message.content.startswith("search keyword"):
k = message.content.split("search keyword ")[1]
await message.channel.send(listSuggest(k))
elif message.content.startswith("summary of keyword"):
k = message.content.split("summary of keyword ")[1]
for x in summary(k):
await message.channel.send(x)
client.run("TOKEN")
Tin học, tiếng Anh: informatics, tiếng Pháp: informatique, là một ngành khoa học chuyên nghiên cứu quá trình tự động hóa việc tổ chức, lưu trữ, xử lý và truyền dẫn thông tin của một hệ thống máy tính cụ thể hoặc trừu tượng (ảo). Với cách hiểu hiện nay, tin học bao hàm tất cả các nghiên cứu và kỹ thuật có liên quan đến việc mô phỏng, biến đổi và tái tạo thông tin.
Nguồn : Wikipedia - Bách khoa toàn thưLớp 7 - Năm thứ hai ở cấp trung học cơ sở, một cuồng quay mới lại đến vẫn bước tiếp trên đường đời học sinh. Học tập vẫn là nhiệm vụ chính!
Nguồn : ADMIN :))Copyright © 2021 HOCTAP247