Download presentation
Presentation is loading. Please wait.
1
CSE3002 Announcements Prof. Steven A. Demurjian
Computer Science & Engineering Department The University of Connecticut 371 Fairfield Way, Box U-255 Storrs, CT (860) 486–4818 (Office) (860) (CSE Office)
2
Upcoming Schedule and Due Dates
PLA6 Golang Assignment – Monday April 24, 11:59pm Among PLA1, PLA2, PLA3, PLA5, PLA6, take four highest Presentations Thursday, April 13 – Groups A and B Tuesday, April 19 – Groups C and D Thursday, April 20 – Groups E and F Tuesday, April Groups G and H Final Project Submittal: Friday April 28 at midnight at 11:59pm:
3
Grading Guesstimates – 30%PLA/20%Movie
4
Grading Guesstimates – 40%PLA/10%Movie
5
Reminders PLA4 Assignment Extend PLAv3 Due March 9, 11:59pm
One-page list of issues/questions on your Topic Why exactly, did things in your topic unfolded as they did. What are the implications? How the history of computing unfold in your topic? What lessons we can draw or learn for the future in your topic? Due March 2, 11:59pm HoC Movie Assignment Due Date: March 22, :59pm
6
PL5 Logic Programming with Prolog Due Monday, April 3, 11:59pm.
Relational database consisting of four tables of information on suppliers (S), parts (P), projects (J), project (SPJ) Supplier numbers (S#), part numbers (P#), and project numbers (J#), are unique in tables S, P, and J Represent DB as Prolog Facts Define Relevant Prolog Rules Write Prolog Queries
7
Databases Tables
8
Prolog Facts and Rules supp(s# sname status city)
part(p# pname color weight city) proj(j# jname city) sppj(s# p# j# qty) suppliesparts(S,P,N,T,C,J,A):-supp(S,N,T,C),sppj(S,P,J,A). usedbyproject(P,N,C,A,L,S,J,D):-part(P,N,C,A,L),sppj(S,P,J,D). usesparts(J,A,B,P,N,S,J,X,G,H):- proj(J,A,B), sppj(S,P,J,X), part(P,N,G,H). notinlocation(S,N,T,C,J,A,B):-supp(S,N,T,C),proj(J,A,B), not(C=B).
9
Prolog Queries When given a pair of projects, find all suppliers who supply both projects. Return the entire entry (i.e., S#, Sname, Status, City) for the supplier. When given a city, find all parts supplied to any project in that city. Once again, return the entire entry for the part. Find all parts supplied to any project by a supplier in the same city. In this case, results are organized by all parts for every city in the database. Find all projects supplied by at least one supplier not in the same city. Find all suppliers that supply at least one part supplied by at least one supplier who supplies at least one red part. Find all pairs of city values such that a supplier in the first city supplies a project in the second city. Find all triples of city, part#, city, such that a supplier in the first city supplies the specified part to a project in the second city, and the two city values are different. When given a supplier, find all projects supplied entirely by that supplier.
10
PL4 Word Index Using Strings in Ada Due March 9, 11:59pm
Extend PLA3v3 with a word index that tracks the line(s) within the input file where each word occurs. There may be multiple occurrences of the word in a file. Current output of PLA3v3 is: Goodbye 4 Hello 1 World 1 You are to update the output to: Goodbye: in lines wc=4 Hello: in lines 3 wc=1 World: in lines 3 wc=1 Assume: Each word must be at least one character and start with a letter. If a word has 2 or more characters, then the second and successive characters can be letters, digits, the underscore, or the hyphen
11
new_u_words_min.adb -- Read one word per line and print list of unique words and their frequencies -- Case sensitive -- This is a minimalist version. No bells or whistles. with ada.integer_text_io; use ada.integer_text_io; with ada.text_io; use ada.text_io; procedure new_u_words_min is type Word is record s: String( ); -- The string. Assume 120 characters or less wlen: Natural; Length of the word Count: Natural := 0; -- Total number of occurrences of this word LineNo: Natural :=0; -- Word found on LineNo end record; type Word_Array is array( ) of Word; type Word_List is record words: Word_Array; The unique words Num_Words: Natural := 0; -- How many unique words seen so far curr_line: Natural := 1; -- Current Line
12
new_u_words_min.adb procedure get_words(wl: out Word_List) is begin
wl.num_words := 0; -- only to get rid of a warning while not End_of_File loop declare s: String := Get_Line; found: Boolean := false; for i in 1 .. wl.num_words loop if s = wl.words(i).s(1 .. wl.words(i).wlen) then wl.words(i).count := wl.words(i).count + 1; found := true; end if; exit when found; end loop; if not found then -- Add word to list wl.num_words := wl.num_words + 1; wl.words(wl.num_words).s(1 .. s'last) := s; wl.words(wl.num_words).wlen := s'length; Wl.Words(Wl.Num_Words).Count := 1; Wl.Words(Wl.Num_Words).LineNo:= wl.curr_line; -- set LineNo of word wl.curr_line := wl.curr_line + 1; -- one word per line so increase curr_line end; -- declare end get_words;
13
new_u_words_min.adb procedure put_words(wl: Word_List) is begin
for i in 1 .. wl.num_words loop put(wl.words(i).LineNo); put(wl.words(i).count); put(" " & wl.words(i).s(1 .. wl.words(i).wlen)); new_line; end loop; end put_words; the_words: Word_List; get_words(the_words); put_words(the_words); end new_u_words_min;
14
Output of Revised Program
First number is last line it appeared Second number occurence
15
Suggested Solution Approach
Build an dedicated output string for the word, its occurrences in lines, and final word count. Programmatically, for the word “Goodbye” the string would be built in the following steps: Goodbye in lines: create when the word is first found Goodbye in lines: append “ 1” when the word is first found Goodbye in lines: append “-2” when the word is found in line 2 Goodbye in lines: append “-5” when the word is found in line 5 Goodbye in lines: append “6” when the word is found in line 7 Goodbye in lines: append “6” when the word is found again in line 7 -- Etc… Built as the words are recognized on each line After EOF reached for all words, you print out the new dedicated output string for the word and append “wc=” and then print out the word count 5 as an integer You can also convert the word count to string and append
16
PL3 Software Evolution of an Ada Program - Due February 23, 11:59pm
Modify an existing word frequency function Ada program (u_words_min.adb) or (u_words_tight.adb) This programming project is an exercise in learning a new language by having to modify and extend someone else’s code
17
Two Current Ada Programs
Assume a word of 20 characters as a string – in the posted web copies of the two files, this has been increased to 120 Assumes one word per line including spaces Generated Output as follows/Use CTRL-Z <CR>
18
Three Versions V1 Change the original program to alphabetically sort the outputted list of words – first executable. V2 + V1 Change the logic so that the words within each line are identified – this would then result in a full word frequency functionality and if the sort has been implemented, it will now sort the entire list – second executable. V3+V1+V2 Change the program so that the data is read from input.txt and written to output.tex – third executable.
19
u_words_min.adb -- Read one word per line and print list of unique words and their frequencies -- Case sensitive -- This is a minimalist version. No bells or whistles. with ada.integer_text_io; use ada.integer_text_io; with ada.text_io; use ada.text_io; procedure u_words_min is type Word is record s: String( ); -- The string. Assume 120 characters or less wlen: Natural; Length of the word count: Natural := 0; -- Total number of occurrences of this word end record; type Word_Array is array( ) of Word; type Word_List is record words: Word_Array; The unique words num_words: Natural := 0; How many unique words seen so far
20
u_words_min.adb procedure get_words(wl: out Word_List) is begin
wl.num_words := 0; -- only to get rid of a warning while not End_of_File loop declare s: String := Get_Line; found: Boolean := false; for i in 1 .. wl.num_words loop if s = wl.words(i).s(1 .. wl.words(i).wlen) then wl.words(i).count := wl.words(i).count + 1; found := true; end if; exit when found; end loop; if not found then -- Add word to list wl.num_words := wl.num_words + 1; wl.words(wl.num_words).s(1 .. s'last) := s; wl.words(wl.num_words).wlen := s'length; wl.words(wl.num_words).count := 1; end; -- declare end get_words;
21
u_words_min.adb procedure put_words(wl: Word_List) is begin
for i in 1 .. wl.num_words loop put(wl.words(i).count); put(" " & wl.words(i).s(1 .. wl.words(i).wlen)); new_line; end loop; end put_words; the_words: Word_List; get_words(the_words); put_words(the_words); end u_words_min;
22
u_words_tight.adb -- Read one word per line and print list of unique words and their frequencies -- Case sensitive -- This is a minimalist version. No bells or whistles. with ada.integer_text_io; use ada.integer_text_io; with ada.text_io; use ada.text_io; procedure u_words_min is type Word is record s: String( ); -- The string. Assume 120 characters or less wlen: Natural; Length of the word count: Natural := 0; -- Total number of occurrences of this word end record; type Word_Array is array( ) of Word; type Word_List is record words: Word_Array; The unique words num_words: Natural := 0; How many unique words seen so far
23
u_words_tight.adb -- Read one word per line and print list of unique words and their frequencies -- Case sensitive -- This is a minimalist version. No bells or whistles. with ada.integer_text_io; use ada.integer_text_io; with ada.text_io; use ada.text_io; procedure u_words_min is type Word is record s: String( ); -- The string. Assume 120 characters or less wlen: Natural; Length of the word count: Natural := 0; -- Total number of occurrences of this word end record; type Word_Array is array( ) of Word; type Word_List is record words: Word_Array; The unique words num_words: Natural := 0; How many unique words seen so far
24
u_words_tight.adb -- Read one word per line and print list of unique words and their frequencies -- Case sensitive -- This is a minimalist version. No bells or whistles. -- This version has a fast inner loop. It has only one comparison. -- This is done by always putting the word being sought at the -- end of the list. If the word being sought is found earlier -- in the list, then the value at the end is ignored. If it is -- not found earlier, then it has already been added. -- The final location in the list can't hold a word that is -- being counted. It can only be used to hold a sentinal during -- a search. with ada.integer_text_io; use ada.integer_text_io; with ada.text_io; use ada.text_io; procedure u_words_tight is type Word is record str: String ( ); -- The string. Assume 120 characters or less wlen: Natural; Length of the word count: Natural := 1; Total number of occurrences of this word end record; type Word_Array is array( ) of Word; type Word_List is record words: Word_Array; The unique words num_words: Natural; How many unique words seen so far
25
u_words_tight.adb procedure get_words (wl: out Word_List) is
i : Natural; begin wl.num_words := 0; -- Initialize here to avoid a warning while not End_of_File loop declare s: String := Get_Line; wl.words (wl.num_words + 1).str (1 .. s'Last) := s; wl.words (wl.num_words + 1).wlen := s'Length; i := 1; while s /= wl.words (i).str (1 .. wl.words (i).wlen) loop i := i + 1; end loop; -- s = wl.words(i) if i = wl.num_words + 1 then wl.num_words := wl.num_words + 1; else wl.words(i).count := wl.words(i).count + 1; end if; end; -- declare end get_words;
26
u_words_tight.adb procedure put_words (wl: Word_List) is begin
for i in 1 .. wl.num_words loop put (wl.words(i).count); put (" " & wl.words(i).str(1 .. wl.words(i).wlen)); new_line; end loop; end put_words; the_words: Word_List; get_words (the_words); put_words (the_words); end u_words_tight;
27
PL2 Modula-2 Program - Due February 9, 11:59pm
Implement the Word Frequency Functional (WFF) in Modula-2 using findwords.mod as a basis: You need to develop a dual solution (two programs): Single module solution using records based off of findwords.mod sample code that outputs to stdout a list of words and their frequency. Single module reworking your solution from I into a read procedure that reads the lines into the document variable of type AllLines, a wff procedure that generates the word frequency in the wordsindoc variable of type AllWords &WordFreq record, and a sortandprint procedure that outputs to stdout a list of words and their frequency in alphabetical order.
28
Expanding the Sample Program
program readwritetofiles; var readfilename : string; writefilename : string; myreadfile : text; mywritefile : text; line : packed array [1..100] of char; i : integer; num_characters: integer; begin (* put files in c:\Dev-Pas directory *) readfilename:='inputfile.txt'; writefilename:='outputfile.txt'; assign(myreadfile, readfilename); reset(myreadfile); assign(mywritefile, writefilename); rewrite(mywritefile); while NOT EOF (myreadfile) do readln(myreadfile, line); num_characters := 0; for i:=1 to 100 do if ord(line[i]) <> 0 then num_characters := num_characters + 1; write(mywritefile, line[i]) end; writeln(mywritefile, num_characters); writeln(mywritefile,'Completed writing'); close(myreadfile); close(mywritefile); end.
29
Expanding the Sample Program
line : packed array [1..100] of char; i : integer; num_characters: integer; while NOT EOF (myreadfile) do begin readln(myreadfile, line); num_characters := 0; for i:=1 to 100 do if ord(line[i]) <> 0 then num_characters := num_characters + 1; write(mywritefile, line[i]) end; writeln(mywritefile, num_characters);
30
Input Desk Set (1957) Billion Dollar Brain (1967)
2001: A Space Odyssey (1968) The Computer Wore Tennis Shoes (1969) Colossus: The Forbin Project (1970) The Andromeda Strain (1971) The Aries Computer (1972) Demon Seed (1977) Blade Runner (1982) Tron (1982) WarGames (1983) Electric Dreams (1984) D.A.R.Y.L. (1985) Prime Risk (1985) Flight of the Navigator (1986) Short Circuit (1986) Defense Play (1989) Sneakers (1992) Disclosure (1994) Hackers (1995) The Net (1995)
31
Output Desk Set (1957)15 Billion Dollar Brain (1967)27
2001: A Space Odyssey (1968)28 The Computer Wore Tennis Shoes (1969)37 Colossus: The Forbin Project (1970))36 The Andromeda Strain (1971) (1970))35 The Aries Computer (1972)) (1970))34 Demon Seed (1977) (1972)) (1970))33 Blade Runner (1982)1972)) (1970))33 Tron (1982) (1982)1972)) (1970))32 WarGames (1983)82)1972)) (1970))32 Electric Dreams (1984)2)) (1970))33 D.A.R.Y.L. (1985)984)2)) (1970))32 Prime Risk (1985)984)2)) (1970))32 Flight of the Navigator (1986)970))35 Short Circuit (1986)or (1986)970))34 Defense Play (1989)or (1986)970))33 Sneakers (1992)89)or (1986)970))32 Disclosure (1994))or (1986)970))32 Hackers (1995)4))or (1986)970))31 The Net (1995)4))or (1986)970))31 Completed writingCompleted writing
32
Today’s Speaker – Prof. Keith Barker
University Teaching Fellow at UConn Professor of CS&E Professor of Education Curriculum & Instruction Former Positions at Uconn Department Head in CSE Associate Vice Provost for Undergraduate Education & Instruction and the Director of Institute for Teaching and Learning (ITL) Leader of Computer Engineering Curriculum in CSE Developing Logic Circuit Design (at least twice) Involvement in Accreditation for CSE, CS, CompE in ABET and CSAB Past Chair of CS Accreditation Committee One of three faculty in CSE longer than Steve
33
Today’s Speaker – Prof. Heidi Ellis
Ph.D. CSE, UConn, 1995 Professor at Western New England University Former Department Head Leader in Humanitarian Free and Open Source Software PI of Multiple NSF Awards Recognized by Business Insider Week 26 of the most powerful female engineers in 2016 Nominated for 2016 Women in Open Source Award by Redhat
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.