CSE 163
Intro to HW4�
Suh Young Choi�
🎶 Listening to: The Killers
💬 Before Class: Are animals better when they’re orbular or angular (aesthetically)?
This Time
Last Time
2
Announcements
Midterm evaluations dropping next week
Suh Young out of state again in Week 9
3
Lesson 13 Recap
Class methods and fields can be private
Default parameters
Lambda functions
4
Main Method Pattern
5
def main():
print('Hello world')
if __name__ == '__main__':
main()
Building Dogs
6
d1 = Dog('Chester')
d2 = Dog('Scout')
d3 = d1
d4 = Dog('Chester')
d1
name: 'Chester'
d2
name: 'Scout'
d3
d4
name: 'Chester'
Special Methods
7
Syntax | Method |
x < y | x.__lt__(y) |
x == y | x.__eq__(y) |
x >= y | x.__ge__(y) |
print(x) | print(x.__str__()) |
x[i] | x.__getitem__(i) |
x[i] = v | x.__setitem__(i, v) |
os
8
import os
for file_name in os.listdir(directory_name):
print(file_name) # relative path
print(os.path.join(directory_name,
file_name)) # absolute path
Don’t forget absolute paths!!
9
Only os.path.join() deals in absolutes
SearchEngine
10
Project Part 0 Coming Soon
Project has a few parts
Bonus Project Component releasing next Friday
Project can be completed in groups of ≤3, but bonus component is to be completed individually.
11
Before Next Time
Next Time
12
Slides from Video
13
Search Engine
14
SearchEngine
15
search
16
Document Ranking
17
Dogs are the most amazing pets. Dogs are way better than cats because they are the best pets.
a - An article...
aardvark - An animal...
...
avocado - A fruit…
...
dog - The best pet…
...
dogs_rock.txt
dictionary.txt
TF-IDF
Score(“the dogs”, D) = TFIDF(“the”, D) + TFIDF(“dogs”, D)
TFIDF(t, D) = TF(t, D) * IDF(t)
TF(t, D) = (# of times t in D) / (# of words in D)
IDF(t) = (# of documents) / (# of documents that have t)
18
TF-IDF
19
How to compute TF-IDF
20
Testing
21
Development Strategy
22