A search engine takes a given search phrase or word and finds pages on the internet that are relevant, ranks the pages, and then displays the pages in the order of ranking. For the CSCI 120 project, you will build a simplified search engine that returns articles in no particular order from searching a single keyword. Submission You will be using Mimir to write code in search.py and search_tests.py. Make sure to select the entire folder when submitting the assignment so all files given to you in the starter code are included.
*search.py: file for adding search functionality search_tests.py:
*file for adding unit and integration tests wiki.py: provided functions to help you write the search code - do not change this file article_titles():
*returns complete list of article titles our search engine will have access to ask_search(): asks user for a keyword to search for ask_advanced_search():
*displays and asks user for advanced options search search_tests_helper.py:
*provided functions to help you write test code - do not change this file print_basic():
*returns string to ask user for basic search keyword print_advanced(): returns string to ask user for advanced search option print_advanced_option():
*returns string to ask user for advanced search question get_print(): returns printed string when running entire search program run_tests.py and check_tests.py:
*Ignore these but turn them in along with other files mentioned above Part 1: Searching Article Titles In this part of the project, search for article titles. Basic Search To run a basic search, ask the user for a keyword and use the keyword to search through the complete list of articles (from wiki.article_titles()), and return the list of articles that contain the keyword. The search should not be case-sensitive (ie if a user enters “Dogs”, the resulting list should return all titles with “Dogs” and “dogs”).
If the user does not enter anything, return an empty list. This is done in function #1 in search.py. When running a search, the basic search will always be run, and it will always be run before the advanced search. Example Search Keywords Because we are working with a limited set of articles, there are particular searches that will guarantee a result: dog, volleyball, music, programming, travel, photography, soccer. Article title length - user provides a max article title length (in characters). After searching for article titles with the user’s keyword, return only the article titles that do not exceed the max article title length. For example, if the user searched for “dog” and wants a maximum article title length of 25 characters, only return article titles containing the word “dog” with a maximum article title length of 25 characters. Number of articles - user provides a max number of articles to receive. After searching for article titles with the user’s keyword, return the number of articles requested by the user, starting from the first article. If the number of articles requested by the user exceeds the number of articles satisfying the keyword search, return an empty list. Get one random article - user provides a random number. After searching for article titles with the user’s keyword, return only the article title at the index of the user’s random number.
If there are no articles or the index exceeds the length of the articles, return an empty string. Check whether favorite article in list - user provides a favorite article title. After searching for article titles with the user’s keyword, return True if the provided article is included in the returned list of article titles and False otherwise. Multiple keywords - user provides another keyword to search. After searching for article titles with the user’s basic search keyword, search the articles again using this second keyword. Return a combined list of all articles from both search results: the basic search results first in the list followed by the advanced keyword search results. None - user does not want an advanced search. (There is no function for this) User Interface After writing the code in search.py, the outcome will be as follows (all of these examples are for searching for the keyword “dog”, but you may and should try the other keywords mentioned in the Search Keywords section):
1. Article title length
2. Number of articles
3. Get one random article
4. Check whether favorite article in list
5. Multiple keywords
Depending on the advanced search option, the rest of the user interface will be different. Here is an example of each one. Advanced Search #1: article title length
1. Article title length
2. Number of articles
3. Get one random article
4. Check whether favorite article in list
5. Multiple keywords 6. None Please enter a number corresponding to which advanced search you would like to perform:
1 What's the max article title length (in number of characters) you're looking for?
1. Article title length
2. Number of articles
3. Get one random article
4. Check whether favorite article in list
5. Multiple keywords
Your favorite article is in the returned articles! Advanced Search #4: check whether favorite article in list (article is not found) What are you searching for? dog Any advanced searches?
1. Article title length
2. Number of articles
3. Get one random article
4. Check whether favorite article in list
5. Multiple keywords
6. None Please enter a number corresponding to which advanced search you would like to perform.