User:Alexander Roidl/nltkvschatbot

From XPUB & Lens-Based wiki
< User:Alexander Roidl
Revision as of 16:23, 31 January 2018 by Alexander Roidl (talk | contribs) (Created page with "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 unavoida...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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()