class_docstr: Implementation of Dataset class
  
  This is a simple implementation of loading and processing dataset for metapath2vec model.
  
  Args:
      config: dict, some configure parameters.
class_docstr_tok: ["Implementation","of","Dataset","class","This","is","a","simple","implementation","of","loading","and","processing","dataset","for","metapath2vec","model",".","Args",":","config",":","dict",",","some","configure","parameters","."]
docstr: Read words(nodes) from walk files which are produced by sampler.
          
docstr_tok: ["Read","words","(","nodes",")","from","walk","files","which","are","produced","by","sampler","."]
code: def read_words(self):
      """Read words(nodes) from walk files which are produced by sampler."""
      word_freq = dict()
      for walk_file in glob.glob(self.walk_files):
          with open(walk_file, "r") as reader:
              for walk in reader:
                  walk = walk.strip().split()
                  if len(walk) > 1:
                      self.sentences_count += 1
                      for word in walk:
                          if (
                              int(word)
                              >= self.config["paper_start_index"]
                          ):  # remove paper
                              continue
                          else:
                              self.token_count += 1
                              word_freq[word] = (
                                  word_freq.get(word, 0) + 1
                              )
  
      wid = 0
      logging.info("Read %d sentences." % self.sentences_count)
      logging.info("Read %d words." % self.token_count)
      logging.info("%d words have been sampled." % len(word_freq))
      for w, c in word_freq.items():
          if c < self.config["min_count"]:
              continue
          self.word2id[w] = wid
          self.id2word[wid] = w
          self.word2freq[wid] = c
          wid += 1
  
      self.word_count = len(self.word2id)
      logging.info(
          "%d words displayed less than %d(min_count) have been discarded."
          % (
              len(word_freq) - len(self.word2id),
              self.config["min_count"],
          )
      )
  
      pkl.dump(self.word2id, open(self.word2id_file, "wb"))
  
file_path: PGL/legacy/examples/metapath2vec/Dataset.py
imports: import sys
  import os
  import glob
  import numpy
  import tqdm
  import time
  import logging
  import random
  from pgl import heter_graph
  import pickle
label_desc: Use image node_id 2 for calling the Dataset obj's underlying member method code with example usage: obj.read_words() without return types