def __init__(self,
                 name: str,
                 subtrees: List[TMTree],
                 authors: str = '',
                 doi: str = '',
                 citations: int = 0,
                 by_year: bool = True,
                 all_papers: bool = False) -> None:
        """Initialize a new PaperTree with the given <name> and <subtrees>,
        <authors> and <doi>, and with <citations> as the size of the data.

        If <all_papers> is True, then this tree is to be the root of the paper
        tree. In that case, load data about papers from DATA_FILE to build the
        tree.

        If <all_papers> is False, Do NOT load new data.

        <by_year> indicates whether or not the first level of subtrees should be
        the years, followed by each category, subcategory, and so on. If
        <by_year> is False, then the year in the dataset is simply ignored.
        """
        if all_papers:
            tree_inf = _load_papers_to_dict(by_year)
            tree_dict = _build_tree_from_dict(tree_inf)
            TMTree.__init__(self, name, tree_dict, citations)
            self._authors, self._doi = authors, doi
        else:
            TMTree.__init__(self, name, subtrees, citations)
            self._authors, self._doi = authors, doi
Beispiel #2
0
    def __init__(self, name: str, subtrees: List[TMTree], authors: str = '',
                 doi: str = '', citations: int = 0, by_year: bool = True,
                 all_papers: bool = False) -> None:
        """Initialize a new PaperTree with the given <name> and <subtrees>,
        <authors> and <doi>, and with <citations> as the size of the data.

        If <all_papers> is True, then this tree is to be the root of the paper
        tree. In that case, load data about papers from DATA_FILE to build the
        tree.

        If <all_papers> is False, Do NOT load new data.

        <by_year> indicates whether or not the first level of subtrees should be
        the years, followed by each category, subcategory, and so on. If
        <by_year> is False, then the year in the dataset is simply ignored.
        """
        # TODO: Complete this initializer. Your implementation must not
        # TODO: duplicate anything done in the superclass initializer.
        self._doi = doi
        self._authors = authors

        TMTree.__init__(self, name, subtrees, citations)

        if all_papers:
            paper_dict = _load_papers_to_dict(by_year)
            self._subtrees = _build_tree_from_dict(paper_dict)

        if not self._subtrees:
            self.data_size = citations
        else:
            self.data_size = 0
            for t in self._subtrees:
                self.data_size += t.data_size
                t._parent_tree = self
    def __init__(self,
                 name: str,
                 subtrees: List[TMTree],
                 authors: str = '',
                 doi: str = '',
                 citations: int = 0,
                 by_year: bool = True,
                 all_papers: bool = False) -> None:
        """Initialize a new PaperTree with the given <name> and <subtrees>,
        <authors> and <doi>, and with <citations> as the size of the data.

        If <all_papers> is True, then this tree is to be the root of the paper
        tree. In that case, load data about papers from DATA_FILE to build the
        tree.

        If <all_papers> is False, Do NOT load new data.

        <by_year> indicates whether or not the first level of subtrees should be
        the years, followed by each category, subcategory, and so on. If
        <by_year> is False, then the year in the dataset is simply ignored.
        """

        all_sub_tree = []  # all the sub-folders of this folder
        all_data = _load_papers_to_dict(by_year)

        if not all_papers:
            self._authors = authors
            self._doi = doi
            TMTree.__init__(self, name, subtrees, citations)
        else:
            for key in all_data:
                temp_subtree = _build_tree_from_dict(all_data[key])
                all_sub_tree.append(
                    PaperTree(key, temp_subtree, by_year=by_year))

            self._authors = authors
            self._doi = doi
            TMTree.__init__(self, name, all_sub_tree)
Beispiel #4
0
 def __init__(self,
              name: str,
              subtrees: List[TMTree],
              authors: str = '',
              doi: str = '',
              citations: int = 0,
              by_year: bool = True,
              all_papers: bool = False) -> None:
     self._doi = doi
     self._authors = authors
     if all_papers:
         if by_year:
             tree = _build_tree_from_dict(_load_papers_to_dict(True))
             TMTree.__init__(self, name, tree, citations)
         else:
             tree = _build_tree_from_dict(_load_papers_to_dict(False))
             TMTree.__init__(self, name, tree, citations)
     else:
         TMTree.__init__(self, name, subtrees, citations)
     """Initialize a new PaperTree with the given <name> and <subtrees>,
Beispiel #5
0
    def __init__(self,
                 name: str,
                 subtrees: List[TMTree],
                 authors: str = '',
                 doi: str = '',
                 citations: int = 0,
                 by_year: bool = True,
                 all_papers: bool = False) -> None:
        """Initialize a new PaperTree with the given <name> and <subtrees>,
        <authors> and <doi>, and with <citations> as the size of the data.

        If <all_papers> is True, then this tree is to be the root of the paper
        tree. In that case, load data about papers from DATA_FILE to build the
        tree.

        If <all_papers> is False, Do NOT load new data.

        <by_year> indicates whether or not the first level of subtrees should be
        the years, followed by each category, subcategory, and so on. If
        <by_year> is False, then the year in the dataset is simply ignored.
        """
        if subtrees == []:
            TMTree.__init__(self, name, subtrees,
                            citations)  # i.e our file is a
            self._doi = doi
            self._authors = authors
            # self._citation = citations ### Data_size
            self._by_year = by_year
        if not all_papers and subtrees != []:
            TMTree.__init__(self, name, subtrees, citations)
            self._doi = doi
            self._authors = authors
            self._by_year = by_year
        if all_papers:
            x = _get_paper_list(by_year)
            subtrees = _build_tree_from_dict(x)
            TMTree.__init__(self, name, subtrees, citations)
            self._doi = doi
            self._authors = authors
            self._by_year = by_year