User:Jacopo/Prototyping
↪Prototyping
Notes
NLTK
import nltk
import random
lines = open('./language.txt').readlines()
sentence = random.choice(lines)
print(sentence)
Neocapitalism has also discovered some advantages in large scale. Day and night it talks of nothing but city planning and national development. But its real concern is obviously the conditioning of commodity production, which it senses escaping it unless it resorts to this new scale. Academic urbanism has accordingly defined “slums” from the standpoint of postwar neocapitalism. Its techniques of urban renewal are based on sterile, antisituationist criteria.
tokens = nltk.word_tokenize(sentence)
print(tokens)
['Neocapitalism', 'has', 'also', 'discovered', 'some', 'advantages', 'in', 'large', 'scale', '.', 'Day', 'and', 'night', 'it', 'talks', 'of', 'nothing', 'but', 'city', 'planning', 'and', 'national', 'development', '.', 'But', 'its', 'real', 'concern', 'is', 'obviously', 'the', 'conditioning', 'of', 'commodity', 'production', ',', 'which', 'it', 'senses', 'escaping', 'it', 'unless', 'it', 'resorts', 'to', 'this', 'new', 'scale', '.', 'Academic', 'urbanism', 'has', 'accordingly', 'defined', '“', 'slums', '”', 'from', 'the', 'standpoint', 'of', 'postwar', 'neocapitalism', '.', 'Its', 'techniques', 'of', 'urban', 'renewal', 'are', 'based', 'on', 'sterile', ',', 'antisituationist', 'criteria', '.']
It's important to realize that POS tagging is not a fixed property of a word -- but depends on the context of each word. The NLTK book gives an example of homonyms -- words that are written the same, but are actually pronounced differently and have different meanings depending on their use.
text = nltk.word_tokenize("They refuse to permit us to obtain the refuse permit")
nltk.pos_tag(text)
text = nltk.word_tokenize("They refuse to permit us to obtain the refuse permit")
nltk.pos_tag(text)
[('They', 'PRP'),
('refuse', 'VBP'),
('to', 'TO'),
('permit', 'VB'),
('us', 'PRP'),
('to', 'TO'),
('obtain', 'VB'),
('the', 'DT'),
('refuse', 'NN'),
('permit', 'NN')]
Mon 21.09 Lesson 2 w/ Michael
Mon 28.09 Lesson 3 w/ Manetta
Wed 30.09 Lesson 4 w/ Michael
Morning Journey inside some individual experiments.
> Il Pleut Bot (from Federico)
import random
width = 10
height = 10
drops = [',',' ',' ',' ']
rain = ''
for x in range(width):
for y in range(height):
rain += random.choice(drops)
print(rain)
rain = ''
> Responsive Form (from Louisa)
print('Enter your name:')
name = input()
print('Hello, ' + name + ". Are you ready to choose your own adventure? If yes, Type one of these words to kickstart the engine: hot, yellow, bright")<br>
> Differences between LOOP and WHILE
> Differences between FLAT LOOP and NESTING LOOP
PIL
The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library provides extensive file format support, an efficient internal representation, and fairly powerful image processing capabilities. It should provide a solid foundation for a general image processing tool.
Image.blend(use1.convert("RGBA"), use2.convert("RGBA"), 0.5)
#The two images must have the same mode and size
NOTEBOOK of the day: https://git.xpub.nl/XPUB/S13-Words-for-the-Future-notebooks
PAD of the day: https://pad.xpub.nl/p/2020-09-30-prototyping
Wed 07.10 Lesson 5 w/ Michael and Manetta
Today's Goal: Making a A0 Quilt using different patches from XPUB1 Student.
We refer to Patch both as digital and physical part of the Quilt. In the early computer era, the Patch was a set of changes for a computer programme. To update, fix or improve the programme, new paper tape or punched cards were replacing the wrong segment, after being literally cut off.
PAD of the day: https://pad.xpub.nl/p/XPUB1_ONLINE_07_10_2020
Editing an image with: aalibb library
> http://aa-project.sourceforge.net/aalib/
#Patch 2
from PIL import Image
from urllib.request import urlopen
f = Image.open (urlopen("https://here's the link"))
g = f.convert("1") #for b&w
g.save ("bw.png") #to save a new copy
import aalib
screen = aalib.AsciiScreen(width=82, height=74) #size of the canvas
h = f.resize(screen.virtual_size).convert('L',dither=Image.NONE)
screen.put_image((0, 0), h)
print (screen.render())
Links
Check-in:
> https://www.effbot.org/imagingbook/pil-index.htm
> https://pillow.readthedocs.io/en/stable/
Library Sources to work with Images and ASCII:
> http://aa-project.sourceforge.net/aalib/
> http://jwilk.net/software/python-aalib