Review Data Visualization Process. Text Analysis/Text Mining Derive high-quality information on patterns and trends in the text via statistical pattern.

Slides:



Advertisements
Similar presentations
Why not just use Arrays? Java ArrayLists.
Advertisements

Sequence of characters Generalized form Expresses Pattern of strings in a Generalized notation.
Collections Framework A very brief look at Java’s Collection Framework David Davenport May 2010.
CSC 205 – Java Programming II Lecture 25 March 8, 2002.
5-May-15 ArrayLists. 2 ArrayList s and arrays A ArrayList is like an array of Object s Differences between arrays and ArrayList s: Arrays have special.
Dictionaries Chapter Chapter Contents Specifications for the ADT Dictionary Entries and methods Using the ADT Dictionary English Dictionary Telephone.
An Array-Based Implementation of the ADT List public class ListArrayBased implements ListInterface { private static final int MAX_LIST = 50; private Object.
CS 106 Introduction to Computer Science I 05 / 03 / 2010 Instructor: Michael Eckmann.
15-Jun-15 Lists in Java Part of the Collections Framework.
Algorithm Programming Containers in Java Bar-Ilan University תשס " ו by Moshe Fresko.
What Is a Collection?  A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit.  Collections.
24-Jun-15 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 17 Advanced Java Concepts Data Structure Support.
Collections The objectives of this chapter are: To outline the Collections infrastructure in Java To describe the various collection classes To discuss.
Lists in Java Part of the Collections Framework. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection.
12-Jul-15 Lists in Java Part of the Collections Framework.
The Collections Framework A Brief Introduction. Collections A collection is a structured group of objects –An array is a kind of collection –A Vector.
CS 106 Introduction to Computer Science I 04 / 30 / 2010 Instructor: Michael Eckmann.
Dictionaries Chapter Chapter Contents Specifications for the ADT Dictionary A Java Interface Iterators Using the ADT Dictionary A Directory of Telephone.
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Week 11 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Recitation 1 CS0445 Data Structures Mehmud Abliz.
Collections in Java. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection with no duplicates SortedSet.
1 Unit 10 - Data Structures Objectives 1. Describe the usage of data structures. 2. Develop simple data structures. 3. Apply Java collections. 4. Apply.
(c) University of Washington14-1 CSC 143 Java Collections.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
The Java Collections Framework (JCF) Introduction and review 1.
ArrayList, Multidimensional Arrays
Chapter 11 Arrays Continued
1 TCSS 143, Autumn 2004 Lecture Notes Java Collection Framework: Maps and Sets.
Data structures Abstract data types Java classes for Data structures and ADTs.
1/20/03A2-1 CS494 Interfaces and Collection in Java.
Collections in Java. 2 Collections Hierarchy > ArrayListVector Stack LinkedList > Arrays Collections.
1.0tCopyright © 1998 Purple Technology, Inc. 1 Java Collections Framework Authored by Alex Chaffee Copyright © 1998 Purple Technology, Inc. All rights.
The Java Collections Framework Based on
Copyright 2008 by Pearson Education Building Java Programs ArrayList Reading: 10.1.
CSC 142 P 1 CSC 142 Collections [Reading: Chapter 10]
3-February-2003cse Collections © 2003 University of Washington1 Java Collections CSE 403, Winter 2003 Software Engineering
ArrayList Class An ArrayList is an object that contains a sequence of elements that are ordered by position. An ArrayList is an object that contains a.
Java 2 Collections Bartosz Walter Software Engineering II.
ArrayList By Neil Butcher. What is the difference between an ArrayList and an Array? An ArrayList is in many ways similar to an array, but has a few subtle.
1 Collection, Iterable, and Iterator Interfaces The Collection Interface and its Hierarchy The Iterable and Iterator Interfaces For-each Loops with Iterable.
1 Collections Framework A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain:
(c) University of Washington16-1 CSC 143 Java Lists via Links Reading: Ch. 23.
Sets and Maps Computer Science 4 Mr. Gerb Reference: Objective: Understand the two basic applications of searching.
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
CS Ananda Gunawardena.  A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit.  Collections.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
Copyright (c) Systems and Computer Engineering, Carleton University * Object-Oriented Software Development Unit 13 The Collections Framework.
Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
1 Copyright © 2011 Tata Consultancy Services Limited COLLECTIONS By TEAM 5 Rajendhiran Sivan Christi Yashwanth Bijay Smruthi Satyajit.
Collections Dwight Deugo Nesa Matic
C19: Collection Classes (don’t forget to look at all the online code examples)
1 The copy constructor in the BankAccounts class. Two alternatives here: /** copy constructor */ public BankAccounts(BankAccounts L){ theAccounts = L.theAccounts.clone();
19-Mar-16 Collections and ArrayLists.. 2 Collections Why use Collections. Collections and Object-Orientation. ArrayLists. Special Features. Creating ArrayLists.
Click to edit Master text styles Stacks Data Structure.
1 CS162: Introduction to Computer Science II Abstract Data Types.
Fundamental of Java Programming
Efficiency of in Binary Trees
Data Structures Lakshmish Ramaswamy.
COP 3503 FALL 2012 Shayan Javed Lecture 8
Programming in Java Lecture 11: ArrayList
"He's off the map!" - Eternal Sunshine of the Spotless Mind
ArrayLists 22-Feb-19.
Collections Framework
L5. Necessary Java Programming Techniques
Hashing in java.util
Web Design & Development Lecture 6
Presentation transcript:

Review Data Visualization Process

Text Analysis/Text Mining Derive high-quality information on patterns and trends in the text via statistical pattern learning – Word frequency analysis – Sentiment analysis – Text categorization – Text clustering Related fields – Computational Linguistics – Natural Language Processing – Information Retrieval – Machine Learning – Artificial Intelligence

Acquire

Parse and Filter String raw; String delimiters = String[] fileText, words; int[] freqs; void setup() { fileText = loadStrings("EliotLoveSong.txt"); println("Read " + fileText.length + " lines."); raw = join(fileText, " "); raw = raw.toLowerCase(); words = splitTokens(raw, delimiters); println("Found " + words.length + " words."); }

Mine String raw; String delimiters = String[] fileText, words, uniqueWords; int[] freqs; void setup() { fileText = loadStrings("EliotLoveSong.txt"); println("Read " + fileText.length + " lines."); raw = join(fileText, " "); raw = raw.toLowerCase(); words = splitTokens(raw, delimiters); println("Found " + words.length + " words."); freqs = makeUnique(words); println("Found "+uniqueWords.length+" unique words."); }

Data Structures Ways of storing and organizing data Arrays – Must know the size ahead of time – Can not grow and shrink at will

Built-in Collection Classes ArrayList – A built-in object that stores and manages an arbitrary number of data items of any type (Objects). – Objects in an ArrayList are accessed by index [0..size-1] HashMap – A built-in object that stores and manages an arbitrary number of data items of any type (Objects). – Objects in a HashMap are accessed by a key, which can be another Object, frequently a String.

ArrayList Constructors ArrayList lst1 = new ArrayList(); ArrayList lst2 = new ArrayList(int initialSize); Fields Methods size()// Returns the num of items held. add(Object o)// Appends o to end. add(int idx, Object o)// Inserts o at pos idx. remove(int idx)// Removes item at pos idx. get(int idx)// Gets items at idx. No removal. set(int idx, Object o)// Replaces item at idx with o. clear()// Removes all items. isEmpty()// true if empty. toArray() // returns an array that contains // the contents of the list

ArrayList Example – Box Dropper // Box Dropper ArrayList boxes = new ArrayList(); void setup() { size(500, 500); } void draw() { background(0); for (int i = boxes.size()-1; i>=0; i--) { //boxes.get(i).draw(); // Fails. Why? Box b = (Box)boxes.get(i); // Type cast Object->Box if(b.update()) { boxes.remove(i); println(boxes.size() + " boxes remaining"); } else { b.draw(); } void mousePressed() { Box b = new Box(mouseX, mouseY); boxes.add(b); println( boxes.size() + " boxes in ArrayList" ); } // A simple Box class class Box { float x, y, v; Box(float tx, float ty) { x = tx; // x position y = ty; // y position v = 0.0; // y velocity } void draw() { fill(200); rect(x, y, 20, 20); } boolean update(){ y += v; v += 0.02; return (y>height); } Why can we not call draw directly on item in ArrayList? Why do we loop over ArrayList backwards?

ArrayList Example - Fireworks

HashMap Constructors HashMap map1 = new HashMap(); HashMap map2 = new HashMap(int initialCapacity); Fields Methods size()// Returns num of items held. put(Object key, Object o)// Puts o in map at key remove(Object key)// Remove Object at key get(Object key) // Get Object at key containsKey(Object key)// True if map contains key containsValue(Object val) // True if map contains val clear()// Removes all items. isEmpty()// true if empty.

HashMap Example – High Score // HighScore HashMap scores = new HashMap(); void setup() { size(500, 500); // Init HashMap scores.put("Fred", 2); scores.put("Wilma", 4); scores.put("Barney", 10); scores.put("Betty", 5); scores.put("BamBam", 6); scores.put("Pebbles", 5); // Draw once noLoop(); drawMap(scores); } void draw() { } // Draw the HashMap to the sketch void drawMap(HashMap hm) { background(0); fill(255); textSize(20); // Display all scores text( buildScore("Fred", scores), 100, 100); text( buildScore("Wilma", scores), 100, 150); text( buildScore("Barney", scores), 100, 200); text( buildScore("Betty", scores), 100, 250); text( buildScore("BamBam", scores), 100, 300); text( buildScore("Pebbles", scores), 100, 350); redraw(); } // Build a return a String for displaying a Score String buildScore(String name, HashMap hm) { String msg = name + ":" + hm.get(name).toString(); return msg; }

Sorting Any process of arranging items in sequence Build-in sort() – Works on arrays of simple types, i.e. int, float and String – float[] a = { 3.4, 3.6, 2, 0, 7.1 }; – a = sort(a); – String[] s = { "deer", "elephant", "bear", "aardvark", "cat" }; – s = sort(s, 3); Convenient, but not very flexible

Implement your own sort Many sorting algorithms Bubble Sort – Looks at items in successive pairs – Swap if in the wrong order Selection Sort – Scan a list top to bottom and find the value that should come first – Swap that item with the top position – Repeat scan starting at next lowest item in the list – Works best when swapping is expensive

Comparing Sorting Algorithms