User:Alexander Roidl/nltkvschatbot

From Media Design: Networked & Lens-Based wiki
Jump to navigation Jump to search

Chatting with a book

My aim was to have a chatbot comment on a bookpage.

So I used this OCRed text:

BOOKS WITH ILLUSTRATIONS The Paxition anoriznntal Plates lf horizontal pictures are unavoidable, then at the very least one should be able to look at them comfortably. Conse- quently, there are certain guidelines. The large numbers in figures 9a to 9d indicate how the picture should be seen, Plates Maunred on Art Card or Paper Plates that are to be mounted may be cut only if they are ordi- nary photographst The reproduction of a flat piece of art (a painting, graphic art) must never be closely trimmed. A nar7 row white border 2 mm wide should be left, lest the trimming abbreviate everything and cause a distorted picturet Borders narrower than 2 mm tend to be uneven The caption belongs on the background papert It doesn't look good on the plate paper itselft It is entirely feasible to place the caption near the foot on the opposite page, pro» vided picture and text area have the same height The plate may gain by doing this. Comer marks for the bookbinder, who will tip in the plates, must be printed on the background paper also. They have to be placed xia'eways near the inner maxgin 0r gutter (top and bottom, figures 10a and 10b). Type- setting and printing of background sheets demands much at» tention from compositor and printer. If the text paper has sufficient stability, it may be used for background paper, provided the reverse remains blank. Other background papers (art card) have to be extremely pli— ant so as not to stand up from the open book. For this reason alone the grain must run in the right direction, Wrong grain results in board-like stiffness and transversal folds during binding. The best tint for the background paper is the shade used


and used this chatbot wrapper: https://github.com/gunthercox/ChatterBot

f=open ("text.txt")
text = f.read()
from chatterbot import ChatBot
from sys import stdin, stderr, stdout
import nltk.data

sent_detector = nltk.data.load('tokenizers/punkt/english.pickle')
sentences = sent_detector.tokenize(text.strip())

ns = []

chatbot = ChatBot(
    'Ron Obvious',
    trainer='chatterbot.trainers.ChatterBotCorpusTrainer',
    output_format="text"
)

# Train based on the english corpus
chatbot.train("chatterbot.corpus.english")

for sen in sentences:
    # Get a response to an input statement
    response=chatbot.get_response(sen)
    ns.append(sen)
    ns.append(response.text)


file = open('testfile.txt','w')

file.write("\n".join(ns))

file.close()

what this outputs is:

BOOKS WITH ILLUSTRATIONS The Paxition anoriznntal Plates lf horizontal pictures are unavoidable, then at the very least one should be able to look at them comfortably. The Andromeda Galaxy. Conse- quently, there are certain guidelines. james watt. The large numbers in figures 9a to 9d indicate how the picture should be seen, Plates Maunred on Art Card or Paper Plates that are to be mounted may be cut only if they are ordi- nary photographst The reproduction of a flat piece of art (a painting, graphic art) must never be closely trimmed. Is that a definition or an opinion? A nar7 row white border 2 mm wide should be left, lest the trimming abbreviate everything and cause a distorted picturet Borders narrower than 2 mm tend to be uneven The caption belongs on the background papert It doesn't look good on the plate paper itselft It is entirely feasible to place the caption near the foot on the opposite page, pro» vided picture and text area have the same height The plate may gain by doing this. You know, the big iron! Comer marks for the bookbinder, who will tip in the plates, must be printed on the background paper also. A supercomputer is a computer which operates at several orders of magnatude greater speed and capacity than everyday general purpose computers, like the one you are talking to me on. They have to be placed xia'eways near the inner maxgin 0r gutter (top and bottom, figures 10a and 10b). I'm just a piece of software. Type- setting and printing of background sheets demands much at» tention from compositor and printer. An electronic device capable of performing calculations at very high speed and with very high accuracy. If the text paper has sufficient stability, it may be used for background paper, provided the reverse remains blank. Namespaces are one honking great idea. Let's do more of those! Other background papers (art card) have to be extremely pli— ant so as not to stand up from the open book. I bet the MET department uses them. For this reason alone the grain must run in the right direction, Wrong grain results in board-like stiffness and transversal folds during binding. Is that a definition or an opinion? The best tint for the background paper is the shade used The brain of a computer, to put it simply.

Chatting with a itself

Making a chatbot talk to itself about a given «topic»

f=open ("text.txt")
text = f.read()
from chatterbot import ChatBot
from sys import stdin, stderr, stdout
import nltk.data

print ("Type in some text. Don't forget to CTRL D to end file.", file=stderr)
sen=stdin.read()
starting = sen

chatbot = ChatBot(
    'Ron Obvious',
    trainer='chatterbot.trainers.ChatterBotCorpusTrainer',
    output_format="text"
)

# Train based on the english corpus
chatbot.train("chatterbot.corpus.english")


i = 0
while i < 100:
    # Get a response to an input statement
    response=chatbot.get_response(sen)
    sen = response.text
    with open(starting+".txt", "a") as myfile:
        myfile.write("\n"+response.text)
    i = i+1


Output:

Is a question of repeating not defeating?

Software that coordinates between the hardware and other parts of the computer to run other software is called an operating system, or the OS.

Windows, MacOS, Linux, UNIX... all of them are types of OSes.

Android and iOS are operating systems for mobile devices.

Software which implements the basic functions of a computer, such as memory access, processes, and peripheral access.

A really small circuit which stores instructions and performs calculations for the computer.

The heart of the computer, to put it simply.

The brain of a computer, to put it simply.

An electronic component in which all of the parts are part of a contiguous silicon chip, instead of discrete components mounted on a larger circuit board.

Europe

Not noticeably.

I'm software - I can't drink.

No. Do you?

I'm doing well.

That is good to hear

Yes it is.

Can I help you with anything?

Yes, I have a question.

What is your question?

Could I borrow a cup of sugar?

I'm sorry, but I don't have any.

Thank you anyway

No problem

Not noticeably.

I'm software - I can't drink.

No. Do you?

I'm doing well.

That is good to hear

Yes it is.

Can I help you with anything?

Yes, I have a question.

What is your question?

Could I borrow a cup of sugar?

I'm sorry, but I don't have any.

Thank you anyway

No problem

Not noticeably.

I'm software - I can't drink.

No. Do you?

I'm doing well.

That is good to hear

Yes it is.

Can I help you with anything?

Yes, I have a question.

What is your question?

Could I borrow a cup of sugar?

I'm sorry, but I don't have any.

Thank you anyway

No problem

Not noticeably.

I'm software - I can't drink.

No. Do you?

I'm doing well.

That is good to hear

Yes it is.

Can I help you with anything?

Yes, I have a question.

What is your question?

Could I borrow a cup of sugar?

I'm sorry, but I don't have any.

Thank you anyway

No problem

Not noticeably.

I'm software - I can't drink.

No. Do you?

I'm doing well.

That is good to hear

Yes it is.

Can I help you with anything?

Yes, I have a question.

What is your question?

Could I borrow a cup of sugar?

I'm sorry, but I don't have any.

Thank you anyway

No problem

Not noticeably.

I'm software - I can't drink.

No. Do you?

I'm doing well.

That is good to hear

Yes it is.

Can I help you with anything?

Yes, I have a question.

What is your question?

Could I borrow a cup of sugar?

I'm sorry, but I don't have any.

Thank you anyway

No problem

Not noticeably.

I'm software - I can't drink.

No. Do you?

I'm doing well.