class_docstr: Class to read the datasets in RuRED format
docstr: This class processes the RuRED relation extraction dataset
  (http://www.dialog-21.ru/media/5093/gordeevdiplusetal-031.pdf).
  Args:
      data_path: a path to a folder with dataset files.
      rel2id: a path to a file where information about relation to relation id corresponding is stored.
  Returns:
      RuRED output dictionary in the following format:
      DocRED output dictionary in the following format:
      {"data_type":
          List[
              Tuple(
                  List[
                      List[all tokens of the document],
                      List[
                          List[Tuple(start pos of mention 1 of ent 1, end pos of mention 1 of ent 1), ...],
                          List[Tuple(start position of entity 2, end position of entity 2), ...],
                          List[str(NER tag of entity 1), str(NER tag of entity 2)]
                      ],
                  List(int(one-hot encoded relation label))
              )
          ]
      }
docstr_tok: ["This","class","processes","the","RuRED","relation","extraction","dataset","(","http",":","\/\/www.dialog-21.ru\/media\/5093\/gordeevdiplusetal-031.pdf",")",".","Args",":","data_path",":","a","path","to","a","folder","with","dataset","files",".","rel2id",":","a","path","to","a","file","where","information","about","relation","to","relation","id","corresponding","is","stored",".","Returns",":","RuRED","output","dictionary","in","the","following","format",":","DocRED","output","dictionary","in","the","following","format",":","{","``","data_type","''",":","List","[","Tuple","(","List","[","List","[","all","tokens","of","the","document","]",",","List","[","List","[","Tuple","(","start","pos","of","mention","1","of","ent","1",",","end","pos","of","mention","1","of","ent","1",")",",","...","]",",","List","[","Tuple","(","start","position","of","entity","2",",","end","position","of","entity","2",")",",","...","]",",","List","[","str","(","NER","tag","of","entity","1",")",",","str","(","NER","tag","of","entity","2",")","]","]",",","List","(","int","(","one-hot","encoded","relation","label",")",")",")","]","}"]
code: def read(
      self, data_path: str, rel2id: Dict = None
  ) -> Dict[str, List[Tuple]]:
      """
      This class processes the RuRED relation extraction dataset
      (http://www.dialog-21.ru/media/5093/gordeevdiplusetal-031.pdf).
      Args:
          data_path: a path to a folder with dataset files.
          rel2id: a path to a file where information about relation to relation id corresponding is stored.
      Returns:
          RuRED output dictionary in the following format:
          DocRED output dictionary in the following format:
          {"data_type":
              List[
                  Tuple(
                      List[
                          List[all tokens of the document],
                          List[
                              List[Tuple(start pos of mention 1 of ent 1, end pos of mention 1 of ent 1), ...],
                              List[Tuple(start position of entity 2, end position of entity 2), ...],
                              List[str(NER tag of entity 1), str(NER tag of entity 2)]
                          ],
                      List(int(one-hot encoded relation label))
                  )
              ]
          }
      """
  
      data_path = Path(data_path).resolve()
  
      if not rel2id:
          self.rel2id = self.add_default_rel_dict()
      else:
          self.rel2id = rel2id
      self.stat = {}
      self.ner_stat = {}
  
      with open(
          os.path.join(data_path, "train.json"), encoding="utf-8"
      ) as file:
          train_data = json.load(file)
  
      with open(
          os.path.join(data_path, "dev.json"), encoding="utf-8"
      ) as file:
          dev_data = json.load(file)
  
      with open(
          os.path.join(data_path, "test.json"), encoding="utf-8"
      ) as file:
          test_data = json.load(file)
  
      train_data, self.stat["train"] = self.process_rured_file(
          train_data, num_neg_samples="twice"
      )
      dev_data, self.stat["dev"] = self.process_rured_file(
          dev_data, num_neg_samples="equal"
      )
      test_data, self.stat["test"] = self.process_rured_file(
          test_data, num_neg_samples="equal"
      )
  
      data = {"train": train_data, "valid": dev_data, "test": test_data}
  
      return data
  
file_path: DeepPavlov/deeppavlov/dataset_readers/rured_reader.py
imports: import json
  import os
  import random
  from typing import Dict, List, Tuple
  from pathlib import Path
  from logging import getLogger
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.dataset_reader import DatasetReader
label_desc: Use image node_id 1 for calling the RuREDDatasetReader obj's underlying member method code with example usage: obj.read(data_path, rel2id) and returns: data