User:Golubjevaite/2proto: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<div style="font-family: Menlo;padding:20px; width: 450px;"><div class="noautonum"; style= "float:left">__TOC__</div>🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇</div>
<div style="padding:20px; margin:20px; padding-right:40px">
= MONDAYS =
== { V } ==
>>>> pad [https://pad.xpub.nl/p/2020-11-09-xpub2 / link]
>>BashImageGallery > [https://pzwiki.wdka.nl/mediadesign/BashImageGallery / link]
> Notebooks<br>
> Python nltk<br>
[[File:nltk_pimpim.png|700px]]
1. Create the POS index from my source text
<source lang="python">
import nltk
from random import choice
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
source = open("source.txt").read()
tokens = nltk.word_tokenize(source)
pos = nltk.pos_tag(tokens)
index = {}
# index["DT"] = ["THE", ]
# index["NNP"] = ["OF", "PETER", "RABBIT", ...]
for word, tag in pos:
    # print (word, "is", tag)
    if tag not in index:
        index[tag] = []
    index[tag].append(word)
</source>
2. Use the index to transform text
<source lang="python">
i = input()
tokens = nltk.word_tokenize(i)
pos = nltk.pos_tag(tokens)
new = []
for word, tag in pos:
    # print (word,tag)
    # replace word with a random choice from the "hat" of words for the tag
    if tag not in index:
        # print ("no replacement")
        new.append(word)
    else:
        newword = choice(index[tag])
        new.append(newword)
        # print ("replace with", newword)
print (' '.join(new))
</source>
== { IV } ==
>>>> pad [https://pad.xpub.nl/p/2020-11-02-xpub2 / link]
== { III } ==
> kiwi on sandbox [https://hub.xpub.nl/sandbox/kiwi/ / link]
== { II } ==
>>>> pad [https://pad.xpub.nl/p/2020-10-05-xpub2 / link]<br>
> Jupyter Lab<br>
> [https://hub.xpub.nl/sandbox/~mmurtaugh/botswaller.html /sandbox/~mmurtaugh/botswaller.html]<br>
> irc for Python [https://pypi.org/project/irc/ / link]<br>
> installing KIWI IRC on the sandbox<br>
<pre> sudo ./kiwiirc </pre>
> tmux bot
<pre>
chgrp publicweb /tmp/bot
sudo rm /tmp/bot
</pre>
//////<br>
notes:<br>
> helps with lib pip3 instalations on mac
<pre> sudo -H pip3 install something </pre>
== { I } ==
[[File:irc_fun.png|700px]]
IRC with Michael
@ https://webchat.freenode.net/  <br>
> ##xpub channel<br>
> pad [https://pad.xpub.nl/p/2020-09-28-xpub2 / link]
> [https://pzwiki.wdka.nl/mediadesign/Infobot Infobot]
<pre> git clone https://git.xpub.nl/XPUB/infobot.git </pre>
to see the config file <br>
ident > bot name > xpubbot <br>
join_channels > ##xpub
<pre>cd info bot
cat conf/infobot.config
nano conf/infobot.config
</pre>
run the script
<pre> ./infobot </pre>
> reading and copy-pasting [http://www.foo.be/docs/tpj/issues/vol3_2/tpj0302-0002.html "Infobots and Purl" by Kevin Lenzo]
> GIT [https://git.xpub.nl/XPUB/python-irc-bots / python-irc-bots]
= HACKPACT =
= HACKPACT =


Line 18: Line 129:


<br>[[File:webfilter1.png|600px|thumb|left|rgbSplit]]
<br>[[File:webfilter1.png|600px|thumb|left|rgbSplit]]





Latest revision as of 14:43, 24 November 2020

🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇🦇

MONDAYS

{ V }

>>>> pad / link

>>BashImageGallery > / link

> Notebooks
> Python nltk
Nltk pimpim.png


1. Create the POS index from my source text

import nltk
from random import choice

nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')

source = open("source.txt").read()
tokens = nltk.word_tokenize(source)
pos = nltk.pos_tag(tokens)
index = {}
# index["DT"] = ["THE", ]
# index["NNP"] = ["OF", "PETER", "RABBIT", ...]
for word, tag in pos:
    # print (word, "is", tag)
    if tag not in index:
        index[tag] = []
    index[tag].append(word)


2. Use the index to transform text

i = input()
tokens = nltk.word_tokenize(i)
pos = nltk.pos_tag(tokens)
new = []
for word, tag in pos:
    # print (word,tag)
    # replace word with a random choice from the "hat" of words for the tag
    if tag not in index:
        # print ("no replacement")
        new.append(word)
    else:
        newword = choice(index[tag])
        new.append(newword)
        # print ("replace with", newword)
print (' '.join(new))

{ IV }

>>>> pad / link

{ III }

> kiwi on sandbox / link

{ II }

>>>> pad / link
> Jupyter Lab
> /sandbox/~mmurtaugh/botswaller.html
> irc for Python / link
> installing KIWI IRC on the sandbox

 sudo ./kiwiirc 

> tmux bot

chgrp publicweb /tmp/bot
sudo rm /tmp/bot


//////
notes:
> helps with lib pip3 instalations on mac

 sudo -H pip3 install something 

{ I }

Irc fun.png

IRC with Michael @ https://webchat.freenode.net/
> ##xpub channel
> pad / link


> Infobot

 git clone https://git.xpub.nl/XPUB/infobot.git 

to see the config file
ident > bot name > xpubbot
join_channels > ##xpub

cd info bot
cat conf/infobot.config
nano conf/infobot.config

run the script

 ./infobot 

> reading and copy-pasting "Infobots and Purl" by Kevin Lenzo

> GIT / python-irc-bots

HACKPACT

This is just the prototyping I did to get familliar with tools.

getUserMedia

> Webcam filters
> Take photo button + clear button
> Canvas
> rgbSplit
> Javascript
> navigator.mediaDevices.getUserMedia() / link

// Get media stream
navigator.mediaDevices.getUserMedia({video: true, audio: false})

rgbSplit















IRC bot

> Using Michaels reverse bot as a base / link

import irc.bot

> Downloading an img from a url into a folder

import requests # to get image from the web
import shutil # to save it locally
import re

image blend with PIL

# alpha-blend the images with varying values of alpha
alphaBlended1 = Image.blend(image5, image6, alpha=.8)
alphaBlended2 = Image.blend(image5, image6, alpha=.2)
kittenblend