swsnu / swppfall2021

Learning Software Engineering By Building Web Services
28 stars 19 forks source link

Argument of __init__ function in BabynameParser class #22

Open ericagong opened 3 years ago

ericagong commented 3 years ago
def __init__(self, dirname, year):
    """
    (3 points)
    Given directory path and year, extracts the name of a file to open the corresponding file
    and a list of the (rank, male-name, female-name) tuples from the file read by using regex.
    [('1', 'Michael', 'Jessica'), ('2', 'Christopher', 'Ashley'), ....]

    Args:
        dirname (str): The name of the directory where baby name html files are stored.
        year (int): The target year to parse.
    """

1. I am curious that arg dirname is consist of all pathes or just the name of the directory. For example including all path dirname = ": C:\Users\82105\Desktop\swppfall2021-main\swppfall2021-main\hw1\babydata" or "\babydata" If just including "the name of the dir" then dirname = "babydata".

This is confusing because of the following example shows as dirname is including all pathes wheares skeleton seems like meaning name of the directory. Following is the example output posted on swppfall.hw1 readme.md page.

from babyname_parser import BabynameParser parser = BabynameParser("/{YOUR_HW_PATH}/babydata", 2001) parser.year '2001' parser.rank_to_names_tuples [('1', 'Jacob', 'Emily'), ('2', 'Michael', 'Madison'), ('3', 'Matthew', 'Hannah'), ...] parser.parse(lambda rank_to_names_tuple: rank_to_names_tuple[0]) ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', ...] BabynameParser("/{YOUR_HW_PATH}/babydata", 1900) Traceback (most recent call last): File "", line 1, in File "babyname_parser.py", line 61, in decorated raise BabynameFileNotFoundException("No such file: {}".format(filename)) babyname_parser.BabynameFileNotFoundException: No such file: /{YOUR_HW_PATH}/babydata/1900.html`

  1. Also want to confirm that BabynameFileNotFoundException's error message should contain all file path or just the name of the directory.

  2. Finally want to make sure that if i use \ instead of / in python? I'm using window os, path represents in C:\Users\82105\Desktop\swppfall2021-main\swppfall2021-main\hw1 format not in / format.

  3. It is not related question but want to make it clear... .idea , pycache, README>md should not be included in submission root directory?

chang-jin commented 3 years ago
  1. The comment could be confusing, but, yes. dirname in BabynameParser means a path of the directory.
  2. BabynameFileNotFoundException's error message SHOULD contain all file path as well.
  3. That's one of the reasons why we strongly recommend not use Windows as OS. We will grade your codes on Linux, so please check your code is working correctly in Linux VM. (https://github.com/swsnu/swppfall2021/issues/2)
  4. Actually, those files won't affect your homework grades. But as mentioned in the Git practice session, it would better to exclude local files such as .idea or pycache from your repo through .gitignore.

Thank you for asking important questions! Please let me know when you have other questions.

kdh0102 commented 3 years ago

Regarding question 3, please use os.path.join instead of writing the separator directly in the string. Then you will be OK.

ericagong commented 3 years ago

Thanks a lot! I submitted well :)