(self)
| 158 | |
| 159 | @time_it(freq=20) |
| 160 | def next(self): |
| 161 | if self.end_of_data: |
| 162 | self.end_of_data = False |
| 163 | self.reset() |
| 164 | raise StopIteration |
| 165 | |
| 166 | source = [] |
| 167 | target = [] |
| 168 | hist_item_list = [] |
| 169 | hist_cate_list = [] |
| 170 | hist_shop_list = [] |
| 171 | hist_node_list = [] |
| 172 | hist_product_list = [] |
| 173 | hist_brand_list = [] |
| 174 | |
| 175 | neg_hist_item_list = [] |
| 176 | neg_hist_cate_list = [] |
| 177 | neg_hist_shop_list = [] |
| 178 | neg_hist_node_list = [] |
| 179 | neg_hist_product_list = [] |
| 180 | neg_hist_brand_list = [] |
| 181 | count = 0 |
| 182 | if len(self.source_buffer) == 0: |
| 183 | for k_ in xrange(self.batch_size): |
| 184 | ss = self.source.readline() |
| 185 | if ss == "" and count < self.batch_size: |
| 186 | self.end_of_data = True |
| 187 | self.source.seek(0) |
| 188 | ss = self.source.readline() |
| 189 | self.source_buffer.append(ss.strip().split("^H")) |
| 190 | count += 1 |
| 191 | |
| 192 | if len(self.source_buffer) == 0: |
| 193 | self.end_of_data = False |
| 194 | self.reset() |
| 195 | raise StopIteration |
| 196 | try: |
| 197 | |
| 198 | # actual work here |
| 199 | while True: |
| 200 | |
| 201 | # read from source file and map to word index |
| 202 | try: |
| 203 | ss = self.source_buffer.pop() |
| 204 | except IndexError: |
| 205 | break |
| 206 | uid = self.map_user(ss[0]) |
| 207 | hist_item = map(self.map_item, ss[1].split('\003')) |
| 208 | hist_cate = map(self.map_cate, ss[2].split('\003')) |
| 209 | hist_shop = map(self.map_shop, ss[3].split('\003')) |
| 210 | hist_node = map(self.map_node, ss[4].split('\003')) |
| 211 | hist_product = map(self.map_product, ss[5].split('\003')) |
| 212 | hist_brand = map(self.map_brand, ss[6].split('\003')) |
| 213 | |
| 214 | pos_item = hist_item[-1] |
| 215 | pos_cate = hist_cate[-1] |
| 216 | pos_shop = hist_shop[-1] |
| 217 | pos_node = hist_node[-1] |
nothing calls this directly
no test coverage detected