Pythondisnakespacy-stanzadisnakeDiscord APIspacy-stanza
disnakespacy-stanza
import disnakefrom disnake.ext import commandsimport spacyimport stanza# spacystanzastanza.download('en')nlp = spacy.load("en_core_web_sm")bot = commands.Bot(command_prefix='!')@bot.eventasync def on_ready(): print(f'Logged in as {bot.user}!')@bot.command()async def ask(ctx, *, question): # spacy doc = nlp(question) for token in doc: if token.lemma_ in ['refund', 'money back', 'return']: await ctx.send(": []") return await ctx.send("")bot.run('YOUR_DISCORD_BOT_TOKEN')
spacybot
disnakespacy-stanzaspacystanza
import disnakefrom disnake.ext import commandsimport spacyimport stanza# stanza.download('fr')stanza.download('es')nlp_en = spacy.load("en_core_web_sm")nlp_fr = spacy.load("fr_core_news_sm")nlp_es = spacy.load("es_core_news_sm")bot = commands.Bot(command_prefix='!')@bot.eventasync def on_ready(): print(f'Logged in as {bot.user}!')@bot.command()async def ask(ctx, *, question): user_language = ctx.message.content.split()[0] # doc = None if user_language == '!en': doc = nlp_en(question) elif user_language == '!fr': doc = nlp_fr(question) elif user_language == '!es': doc = nlp_es(question) if doc: for token in doc: if token.lemma_ in ['refund', 'remboursement', 'reembolso']: await ctx.send("Please visit our refund page: [Refund Link]") return await ctx.send("Sorry, I didn't understand your question.")bot.run('YOUR_DISCORD_BOT_TOKEN')
spacy
disnakespacy-stanza
import disnakefrom disnake.ext import commandsimport spacyfrom spacy.lang.en import Englishnlp_en = spacy.load("en_core_web_sm")bot = commands.Bot(command_prefix='!')@bot.eventasync def on_ready(): print(f'Logged in as {bot.user}!')@bot.command()async def feelings(ctx, *, message): doc = nlp_en(message) sentiment = "" if "happy" in message or "great" in message: sentiment = "That's awesome! " elif "sad" in message or "bad" in message: sentiment = "I'm sorry to hear that. " else: sentiment = "Thanks for sharing!" await ctx.send(sentiment)bot.run('YOUR_DISCORD_BOT_TOKEN')
“happy”“sad”
spacystanzaRate LimitAPI
disnakespacy-stanzaPython