1     def __init__(self):
2         self.load_me_stories = story_loader.StoryLoader()
3 
4         self.movies_map = dict()
5         self.qa_list = list()
6         self.data_split = dict()
7 
8         self._populate_movie()
9         self._populate_splits()
10        self._populate_qa()
11        print 'Initialized MovieQA data loader!'

Figure 1: Flowchart of __init__ function

__init__是class 的constructor function,傳入的參數就是class本身。

首先呼叫story_loader module裡面的StoryLoader(),把結果存進self.load_me_stories變數。

再來初始self.movies_mapself.data_split為空的dict物件,self.qa_list為空的list物件。

接著self._populate_movie()被呼叫,把資料存入self.movies_mapself.movies_map_inv

self._populate_qa()被呼叫,資料存入self.qa_list

self._populate_splits()被呼叫,資料存入self.data_split

最後執行print 'Initialized MovieQA data loader!',把'Initialized MovieQA data loader!' print到screen。

results matching ""

    No results matching ""