this notebook is not yet tested to run remotely on lyrik, some paths and venv configurations need to be adjusted

make sure this notebook is started in a python3 venv with the necessary requirements installed

  • mkvirtualenv --python=/usr/bin/python3 eco3
  • workon eco3
  • cd eco_dir/src/python/irc
  • pip install -r requirements.txt

the upcoming code blocks below can be run in the terminal via

  • cd eco_dir/src/python/irc/
  • workon eco3
  • python irc_bot.py --txt_path /home/mar/code/marcel/ECO/src/python/utils/test_pdfs_txt/roy_ascott1-art_technology_consciousness..txt --server localhost

In [ ]:
import markov_python3
from irc_bot import EcoIrcClient
import os

In [ ]:
# adjust these two vars
txt_path = '/home/mar/code/marcel/ECO/src/python/utils/test_pdfs_txt/roy_ascott1-art_technology_consciousness..txt'
server = 'localhost'

file_path, file_name = os.path.split(txt_path)
lines = open(txt_path, 'r').readlines()

In [ ]:
author = file_name.partition('-')[0]
markov_chain = markov_python3.Markov(prefix=author)

for s in lines:
    markov_chain.add_line_to_index(s.split())

print('Done training ' + author)

the next block will crash, because the last call is blocking <handle_forever()> it works nontheless, just looks ugly in here.


In [ ]:
client = EcoIrcClient(author, markov_chain, file_name)
client.connect(server, tls=False)
client.handle_forever()