class_docstr: Train data loader for NAML model.
  The model require a special type of data format, where each instance contains a label, impresion id, user id,
  the candidate news articles and user's clicked news article. Articles are represented by title words,
  body words, verts and subverts.
  
  Iterator will not load the whole data into memory. Instead, it loads data into memory
  per mini-batch, so that large files can be used as input data.
  
  Attributes:
      col_spliter (str): column spliter in one line.
      ID_spliter (str): ID spliter in one line.
      batch_size (int): the samples num in one batch.
      title_size (int): max word num in news title.
      his_size (int): max clicked news num in user click history.
      npratio (int): negaive and positive ratio used in negative sampling. -1 means no need of negtive sampling.
class_docstr_tok: ["Train","data","loader","for","NAML","model",".","The","model","require","a","special","type","of","data","format",",","where","each","instance","contains","a","label",",","impresion","id",",","user","id",",","the","candidate","news","articles","and","user","'s","clicked","news","article",".","Articles","are","represented","by","title","words",",","body","words",",","verts","and","subverts",".","Iterator","will","not","load","the","whole","data","into","memory",".","Instead",",","it","loads","data","into","memory","per","mini-batch",",","so","that","large","files","can","be","used","as","input","data",".","Attributes",":","col_spliter","(","str",")",":","column","spliter","in","one","line",".","ID_spliter","(","str",")",":","ID","spliter","in","one","line",".","batch_size","(","int",")",":","the","samples","num","in","one","batch",".","title_size","(","int",")",":","max","word","num","in","news","title",".","his_size","(","int",")",":","max","clicked","news","num","in","user","click","history",".","npratio","(","int",")",":","negaive","and","positive","ratio","used","in","negative","sampling",".","-1","means","no","need","of","negtive","sampling","."]
docstr: Read and parse data from news file and behavior file.
  
  Args:
      news_file (str): A file contains several informations of news.
      beahaviros_file (str): A file contains information of user impressions.
  
  Yields:
      object: An iterator that yields parsed results, in the format of dict.
docstr_tok: ["Read","and","parse","data","from","news","file","and","behavior","file",".","Args",":","news_file","(","str",")",":","A","file","contains","several","informations","of","news",".","beahaviros_file","(","str",")",":","A","file","contains","information","of","user","impressions",".","Yields",":","object",":","An","iterator","that","yields","parsed","results",",","in","the","format","of","dict","."]
code: def load_data_from_file(self, news_file, behavior_file):
      """Read and parse data from news file and behavior file.
  
      Args:
          news_file (str): A file contains several informations of news.
          beahaviros_file (str): A file contains information of user impressions.
  
      Yields:
          object: An iterator that yields parsed results, in the format of dict.
      """
  
      if not hasattr(self, "news_title_index"):
          self.init_news(news_file)
  
      if not hasattr(self, "impr_indexes"):
          self.init_behaviors(behavior_file)
  
      label_list = []
      imp_indexes = []
      user_indexes = []
      candidate_title_indexes = []
      click_title_indexes = []
      cnt = 0
  
      indexes = np.arange(len(self.labels))
  
      if self.npratio > 0:
          np.random.shuffle(indexes)
  
      for index in indexes:
          for (
              label,
              imp_index,
              user_index,
              candidate_title_index,
              click_title_index,
          ) in self.parser_one_line(index):
              candidate_title_indexes.append(candidate_title_index)
              click_title_indexes.append(click_title_index)
              imp_indexes.append(imp_index)
              user_indexes.append(user_index)
              label_list.append(label)
  
              cnt += 1
              if cnt >= self.batch_size:
                  yield self._convert_data(
                      label_list,
                      imp_indexes,
                      user_indexes,
                      candidate_title_indexes,
                      click_title_indexes,
                  )
                  label_list = []
                  imp_indexes = []
                  user_indexes = []
                  candidate_title_indexes = []
                  click_title_indexes = []
                  cnt = 0
  
      if cnt > 0:
          yield self._convert_data(
              label_list,
              imp_indexes,
              user_indexes,
              candidate_title_indexes,
              click_title_indexes,
          )
  
file_path: recommenders/recommenders/models/newsrec/io/mind_iterator.py
imports: import tensorflow
  import numpy
  import pickle
  from recommenders.models.deeprec.io.iterator import BaseIterator
  from recommenders.models.newsrec.newsrec_utils import word_tokenize, newsample
label_desc: Use image node_id 6 for calling the MINDIterator obj's underlying member method code with example usage: obj.load_data_from_file(news_file, behavior_file) without return types