| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- """
- # See: https://pythonhosted.org/chatbot/
- # See: https://www.codeproject.com/Articles/36106/Chatbot-Tutorial
- # See: https://www.smallsurething.com/implementing-the-famous-eliza-chatbot-in-python/
- """
- import logging
- from textblob import TextBlob
- from textblob_fr import PatternTagger, PatternAnalyzer
- logging.basicConfig()
- logger = logging.getLogger()
- logger.setLevel(logging.DEBUG)
- def answer_to(sentence):
- """Main program loop: select a response for the input sentence and return it"""
- logger.debug("> received: %s", sentence)
- blob = TextBlob(sentence, pos_tagger=PatternTagger(), analyzer=PatternAnalyzer())
- print("tags", blob.tags)
- print("phrases", blob.sentences)
- # print("mots", blob.words)
- # print("phrases nom.", blob.noun_phrases)
- print("mot 6:", blob.words[6])
- print("lemma:", blob.words[6].lemmatize())
- # print("pluriel:", blob.words[3].pluralize())
- print("mot 12:", blob.words[12])
- print("lemma:", blob.words[12].lemmatize())
- # print("singulier:", blob.words[12].singularize())
- if __name__ == '__main__':
- msg = ""
- answer_to("Ceci est une phrase de test. J'adore le film \"la soupe aux choux\"")
- # print("Oui monsieur?")
- # while msg != ".":
- # msg = input("> ")
- # print(answer_to(msg))
- # answer_to("This is a test sentence.")
|