bit x bit

ITP class 2011 Spring, teacher: Heather Dewey-Hagborg

……………………..homework for 11th of March …………..

comment on Jaron Lanier “You are not a Gadget” ch. 1-3

I guess the biggest contradiction in his thoughts is when he states how the human mind is not a discrete system, for example, we are trying to put ourselves in boxes, such as the Facebook status (married, single ..), on the other hand he has extreme vision how several things are good or bad, placing things into boxes. And this contradiction goes along the first 3 chapters..

I also find it humorous when he says it was a mistake to create a file system, to have a package for every data-plexus, that makes one unique from the other. And then, he talks about the common Book how bad that it is meshed up and no authors, chapters are separated in it…

rest is discussed in class.
……………………..homework for 4th of March …………..

We are still working on our mailing bot with Yoni. Unfortunately, we still received an error by accessing the Inbox of our NYU e-mail account, as well as sending e-mails.
We used two e-mails to mesh up and generate a new text. The used Brown-corpus: PRESS. The text-masher’s OUTPUT:

The Flaming Lips just based a customization that’s based ( much like their 4-CD programmer Zaireeka ) to be done simultaneously on 12 phones : Â   http : / / www . hippiesaredead . com / 2011 / 02 / flaming-lips-drop-new-tune-for . html Would anyone be based in making this happen on JavaScript ? Â   Maybe Thursday web ? Â   I’d also like to set , you know , just for end .

Afterwards, an N-gram model (3,20) was applied, so the final OUTPUT is the following:
for . html Would anyone be based in making this happen on JavaScript ? à ‚    I ‘ d also like

It is great to see that even with a small training file the OUTPUT is funny, and kinda makes sense. It seems a promising start for our mailbot.

……………………..homework for 25th of February …………..

practicing N-grams
number of N-Grams:3
word-count: 20

We decided to continue to working on the mailing bot, therefore we used the following e-mail for our training file:

I’m thinking of getting one or two. Who’s got experience/info??
My family has a tortoise named Tortugie, he is really boring. Get a puppy…

-Avery

i love turtles.  i had the super tiny ones.  if ure getting those, get the nutrient drops for the shell. prevents it from getting soft.
they do get stinky if  u dont clean the tank.

do!

My parents bought one from LA’s Chinatown and gave it to me.  It was an inch and a half long when I received it.  I brought it to work (since I was at work all of the time) and kept him in a shoe box with some land, water, and vegetation.  Indeed, the environment looked pretty sad, so my coworkers placed bets on when he would die- most hovered at or under six months.  But because my love is bountiful, the turtle survived past six months.  Three years later, he was over a foot long and had an aquarium 5 feet long with a really good filtering system (they tend to sully the water quickly).  It’s a lot of work.  If you are going to get one, look for one with a good personality-perhaps, when you are cruising the turtle aisle, it’s the one that smiles and winks at you.  Maybe you can help save those chinatown ones I’ve seen- red ear sliders.  

I put my turtle and fish together when I was …6? 
and of course the fish disappeared forever

i’ve had turtles and tortoises of all types as pets, as well as worked with them in different settings. shoot some q’s my way if you want

Definitely get a heat lamp and a UV lamp for nutrient production.
Red eared sliders +1
My mom’s is 15 or 16.

and the OUTPUT:
a0Maybe you can help save those chinatown ones I ‘ ve seen – red ear sliders . \ ‘ a0 \ and of course the fish \ ‘

……………………..homework for 18th of February …………..stop tokenizer……………………………
For this homework we decided with Yoni to create the words for the stop tokenizer form the Wikipedia. We downloaded 700Mb articles (wiki dump) and analyzed it. We decided to use the first paragraph of each article; which would start after we recognizing the following pattern: ….. {{ …. }}. After this pattern we take all the words in the article and count them up as long as we don’t hit ==, which means the end of the first paragraph. Then we look for the next article.

Yoni wrote the code in python, which takes the Wikipedia articles, counts the different words and lists out the words that appear more, then 0.005.
the received the following words (stop words):

{‘&quot’: 0.0051210997606092757,
‘and’: 0.022112211232653656,
‘for’: 0.0062533252148792426,
‘on’: 0.0057851324139528652,
‘of’: 0.036904228916694898,
‘is’: 0.014502985874096971,
‘The’: 0.0084720150515421502,
“”’”: 0.0051538842797074075,
‘&lt’: 0.0074676996590573377,
‘or’: 0.0057207646216502223,
“””: 0.0050548264431411437,
‘to’: 0.016033145129250137,
‘as’: 0.0070416372011721656,
‘a’: 0.019688326252224119,
‘in’: 0.018025206970286714,
‘the’: 0.050405225240870474,
‘was’: 0.0079482900807514526,
‘by’: 0.0060312581593003666}

We still need to fix some part of the code (it should not be lower/upper case sensitive ), ‘&quot and other words should be removed…)

here is the source code:

import sys

def addCounts(wordCountInCorpus,wordCountInArticle):
	for word in wordCountInArticle:
		if word in wordCountInCorpus:
			wordCountInCorpus[word] = wordCountInCorpus[word] + 1
		else:
			wordCountInCorpus[word] = 1
	return wordCountInCorpus

def	addPercentages(wordAvgPercentageInCorpus,wordCountInArticle):
	sum = 0
	for word in wordCountInArticle:
		sum = sum + wordCountInArticle[word]
		sum = sum * 1.0
	for word in wordCountInArticle:
		percentage = wordCountInArticle[word] / sum
		if word in wordAvgPercentageInCorpus:
			wordAvgPercentageInCorpus[word] = wordAvgPercentageInCorpus[word] + percentage
		else:
			wordAvgPercentageInCorpus[word] = percentage
	return wordAvgPercentageInCorpus

filename ='wikipediaDump.txt'
if len(sys.argv) > 1:
		filename = sys.argv[1];

startText = 0
onText = 0
inParenthesis = 0
sawParagraph = 0
wordCountInArticle = {}
wordCountInCorpus = {}
wordAvgPercentageInCorpus = {}
wordCount = 0
articlesCount = 0

for line in open(filename):
	for sentence in line.split(". "):
		sentence = sentence.strip(":;,.[]()|\"")
		sentence = sentence.replace(":"," ")
		sentence = sentence.replace(";"," ")
		sentence = sentence.replace(","," ")
		sentence = sentence.replace("."," ")
		sentence = sentence.replace("["," ")
		sentence = sentence.replace("]"," ")
		sentence = sentence.replace("("," ")
		sentence = sentence.replace(")"," ")
		sentence = sentence.replace("|"," ")
		sentence = sentence.replace("\""," ")
		sentence = sentence.replace("  "," ")
		sentence = sentence.strip()
		words = sentence.split(" ")
		if startText == 0: #lookingle for begining of artic
			if "<text" in line:
				articlesCount = articlesCount + 1
				startText = 1
		if startText == 1: # in article
			if line.startswith("=="): #reached end of first paragraph. Sum up &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; 'exit' article
				wordCountInCorpus = addCounts(wordCountInCorpus,wordCountInArticle)
				wordAvgPercentageInCorpus = addPercentages(wordAvgPercentageInCorpus,wordCountInArticle)
				wordCountInArticle = {}
				startText = 0
				onText = 0
				inParenthesis = 0
			if startText == 1: #in first paragraph
				for word in words:
					if ">" in word or "{{" in word or "}}" in word:
						if onText == 0 and ">" in word: #out of <text> portion
							onText = 1
						#count parethesis to know when out of {{}}
						if "{{" in word:
							inParenthesis = inParenthesis + 1
						if "}}" in word:
							inParenthesis = inParenthesis - 1
					elif inParenthesis == 0 and onText and len(word) > 0: #in readable portion of first paragraph
														#
														#start count words!
						word = word.lower()
						wordCount = wordCount + 1
						if word in wordCountInArticle:
							wordCountInArticle[word] = wordCountInArticle[word] + 1
						else:
							wordCountInArticle[word] = 1
#ended reading paragraph
print articlesCount
print wordCount

print ""
wordCountInCorpusFinal = {}
for word in wordCountInCorpus:
	if wordCountInCorpus[word] > articlesCount / 5:
		wordCountInCorpusFinal[word] = wordCountInCorpus[word]

print ""
print ""
print wordCountInCorpusFinal

adj = 1.0 / articlesCount
print adj

wordAvgPercentageInCorpusFinal = {}
for word in wordAvgPercentageInCorpus:
	if wordAvgPercentageInCorpus[word] > articlesCount / 500:
		wordAvgPercentageInCorpusFinal[word] = wordAvgPercentageInCorpus[word] * adj

print wordAvgPercentageInCorpusFinal

#wordAvgPercentageInCorpus = [val * adj for val in 

..........................homework for 11th of February ..............Chatbot: conversation with Jack.................................

We had to make a chatbot after Eliza the psychologist.

Hey. My name is Oracle. Who are you?
Jack
Hi, Jack, you are not in bitxbit. Would you give me your phone number??
3474951312
Hmm, I did not know that. Who are you in love with?
Its a secret
Hmm, I did not know that. What do you think of Alex?
He is annoying
annoying??hahhahaha. That is funny! I know that Yoni is a good lover. What do you think of me?
You are funny

source code of the java program:

package class2.regexes;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Oracle {

		public static void main(String[] args) {

	    	String finalResult = "";

			//open up standard input
		    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		    String inputText = "";

		    boolean introduction = true;		    

		   if (introduction == true){
		    	introduction = introduction();
		   }

		    while (!inputText.equals("exit")){
		    	try {
		    		inputText = br.readLine();
		    	} catch (IOException ioe) {
		    		System.out.println("IO error trying to read input");
		    		System.exit(1);
		    	}

		    	//re-assembly rule #1 * you * me -> * I * you
		    	String regex1 = "you .+ me";
		    	Pattern pattern1 = Pattern.compile(regex1);
		    	Matcher matcher1 = pattern1.matcher(inputText);

		    	//adjective
		    	String adjective = "cute";

		    	String beforeAdjective = "(.+)?([Ss]he|[Hh]e)('s| is)";
		    	Pattern beforeAdjectiveP = Pattern.compile(beforeAdjective);
		    	Matcher beforeAdjectiveM = beforeAdjectiveP.matcher(inputText);

		    	if (matcher1.find()){
		    		String found = matcher1.group();
		    		//System.out.println(found);
		    		//replace "you" with "I"
		    		Pattern you = Pattern.compile("you");
		    		matcher1 = you.matcher(found);
		    		String result1 = matcher1.replaceFirst("I");

		    		//replace "me" with "you"
		    		Pattern me = Pattern.compile("me");
		    		matcher1 = me.matcher(result1);
		    		String result2 = matcher1.replaceFirst("you");	    		

		    		finalResult = "why do you think " + result2 + "?";
		    	}

		    	else if(beforeAdjectiveM.find()){
		    		adjective = beforeAdjectiveM.replaceFirst("");
			    	finalResult = adjective + "??"+ getRandomAnswer() + " I know that " + ITP(getRandom(getNamesLenght()))+ " is " + getAdjective()+ "." + randomQuestion();
		    	}

		    	else{
		    		finalResult = getRandomAnswer() + randomQuestion();
		    	}

		    	System.out.println(finalResult);
		    }

		}

		static String getName(String inputText){

			 String beforeNameRegex = ".+([Ii]m |[Ii] am | name is | calle me | it is | [Ii]t's )";

			 Pattern beforeNamePattern = Pattern.compile(beforeNameRegex);
			 Matcher beforeNameMatcher = beforeNamePattern.matcher(inputText);

			 String name = beforeNameMatcher.replaceFirst("");

			 String afterName = " .*";

			 Pattern afterNamePattern = Pattern.compile(afterName);
			 Matcher afterNameMatcher = afterNamePattern.matcher(name);

			 String name2 = afterNameMatcher.replaceFirst("");
			 return name2;
		}

		static boolean introduction(){
			System.out.println("Hey. My name is Oracle. Who are you?");
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			String inputText = "";

			boolean unknown = true;

		    	try {
		    		inputText = br.readLine();
		    	} catch (IOException ioe) {
		    		System.out.println("IO error trying to read input");
		    		System.exit(1);
		    	}

		    String name = getName(inputText);

		    Pattern nameP;
	    	Matcher nameM;
	    	String result = ", you are not in bitxbit." + randomQuestion() + "?";

	    	for (int i = 0; i < getNamesLenght(); i++){
	    		nameP = Pattern.compile(ITP(i));
	    		nameM = nameP.matcher(name);

	    		if (nameM.find()) {
	    			result = "! I know you! You are a student in bitxbit. Tell me: " + randomQuestion() + "?";
	    			unknown = false;
	    			break;
	    		}
	    	}

		   String finalResultIntro = "Hi, " + getName(name) + result;

		    System.out.println(finalResultIntro);

		    return unknown;
		}
		static int getRandom(int len){
		int rnd = (int)Math.floor(Math.random() * (len-1) +0.5);
		return rnd;
	}

		static String ITP(int i){

			String[] names = new String[7];
			names[0] = "Yoni";
			names[1] = "yoni";
			names[2] = "Eszter";
			names[3] = "Alex";
			names[4] = "Cyrus";
			names[5] = "Ivana";
			names[6] = "Heather";

			return names[i];
	}

		static int getNamesLenght(){
			int lenght = 7;
			return lenght;
	}

		static String getAdjective(){

			String[] adjective = new String[6];
			adjective[0] = "nice";
			adjective[1] = "pretty";
			adjective[2] = "mean";
			adjective[3] = "a good lover";
			adjective[4] = "boring";
			adjective[5] = "skips homework";

			int lenght = adjective.length;
			int random = getRandom(lenght);

			return adjective[random];
		}

		static String randomQuestion(){
			String[] rndQuestion = new String[5];
			rndQuestion[0] = " Who are you in love with" + "?";
			rndQuestion[1] = " What do you think of " + ITP(getRandom(getNamesLenght())) + "?";
			rndQuestion[2] = " What do you think of me?";
			rndQuestion[3] = " Would you give me your phone number?";
			rndQuestion[4] = " Did you make your homework?";

			int lenght = rndQuestion.length;
			int random = getRandom(lenght);
			return rndQuestion[random];
		}

		static String getRandomAnswer(){
			String[] rndAnswer = new String[5];
			rndAnswer[0] = "Hmm, I did not know that.";
			rndAnswer[1] = "Why do you think so?";
			rndAnswer[2] = "hahhahaha. That is funny!";
			rndAnswer[3] = "Oh wooooww!";
			rndAnswer[4] = "I wont tell it to anybody... connecting to server.. ";

			int lenght = rndAnswer.length;
			int random = getRandom(lenght);

			return rndAnswer[random];
		}

		static int getRndQuestionLength(){
			return 2;
		}
	}

……………………………….FIRST HOMEWORK………………………………………………………………..
Turing, Searle

thoughts after John R. Searle: Minds, Brains and Programs

IThe Robot Reply
We out a computer inside the robot, we connect it with the motory – sensory system at let the robot explore the world in its own way. We have some fittest functions, maybe “I prefer taking more distance in a shorter time” or “I want to stand up” or “look for new, interesting situations and explore more”. What is the difference between animals and such robots? What is the difference between these creatures and animals? Is there a quality difference between us and animals? If we get hit, we feel pain- We feel the pain otherwise we would not survive if we would have no sensation what is bad – or good for us. So do an animal. But let’s say, we tell the robot to avoid hitting – in this case it does not evolve from evolution but the function exists.

Evolution of 3D printers, the known cycle. I add the code to a 3D printer, to do reproduce yourself. Let’s say for now, that it somehow receives resources. So it creates the first 3D printer, and both continuo on their mission. After a while we will have lots of lots of 3D printers all over. Sometimes they fail, in a sense that a small error occurs while reproducing – one might become smaller. If it becomes smaller, that one fit into places where one would not have earlier (tunnel) and so on. After a while we might have 3D printers in all size; from tiny ones to huge ones, and of course now the question of resource comes in front and decides which are the 3D printers than currently fit to the world.

thought after Turing: Computing machinery and intelligence

debate:
Are there imaginable computers which would do well on the Turing Test?

(4) the argument of consciousness

I think, therefor I am. I was thinking when I was born – so I was already existing. Or was I really thinking? Or maybe I think more and more (then less and less). At age of three/four most of us start questioning ourselves, we realize that we are the object of the world. Is this when we earn our consciousness or was it is also not a binary state?
Supposedly this is the level dogs ever grow to. Do they stay in an early stage of thinking?
…….
What if the existence of machines seeds from our mind?
What if there is a man, and we start replacing his guts one by one with machine- when is the point when we say he became machine?…