![]() |
CSC148 Introduction to Computer Science
|
| Due: |
|
|---|---|
| Late penalty: | BPTree.py (Thursday April 4) can't be handed in late, in case people need solutions, for part 3. |
| Hand in: | Electronic submit here. Make sure to include members.txt. |
| Groups: | Work in groups of size at most three. |
| Environment: | We will test your code under python in the lab. |
This part of the assignment has you write test cases for the supplied BPTree.py classes. If you remember, the Test Driven Development approach has you ...
What you will do...
Hand in your completed BPTree code, which passes all of your tests. For those that do not finish BPTree.py, I will hand out a solution on midnight. No late assignments accepted.
Marking specifics: BPTree.py (40 marks)
Note: Starter code is BPTree_soln.py, and WebSearch.py. You are now finally in a position to use your BPTree to do something useful. We will use it to conduct some simple searches. First load the BPTree with keys that look like (keyword, documentNumber). Because of the way that the BPTree works and the way tuples compare, these will appear in sorted order in the BPTree. So for example, if 'canada' appears in documents 5, 55, 17, 22, 109, 33, then the keys
To find documents that have all of the keywords 'canada', 'history', '1722', find the intersection of the lists for 'canada', 'history' and '1722'. You might want to take a look at python iterators as a neat, efficient way to do all of this. Create an iterator for each of the keywords you are looking for and then intersect them, in much the same way as one might merge them. Remember, they will appear in documentNumber order.
You should hand in WebSearch.py as well as TestWebSearch.py, which verifies the functioning of your WebSearch class.
An instance of WebSearcher is initialized with a collection of (keyword,documentNumber) pairs. It uses this to build
a BPTree. Once built, the WebSearcher can respond with queries such as ws.intersect([ws.search("canada"), ws.search("history"), ws.search("1722")]).
You may have to add a few methods to your BPTree to get this done well.
You can get started building this class early, by simulating the BPTree search results, returning sorted lists of integers,
and then finding the intersection of these lists.
Marking specifics: BPTree.py (in case you added modifications), WebSearch.py (25 marks)
assertRaises