<commit_before>//check if the tags are present
getYaml = function(tag,object) {
  if (!(tag in object)) {
    alert(tag + " not found in the file! Please generate the file again with the lastest version of phonopy!");
  }
  else {
    return object[tag];
  }
}

//yaml is a file object with the "band.yaml" file
getFromPhononpyFile = function(yaml) {
  var yaml_reader = new FileReader();
  self = this;

  //read the files
  yaml_reader.onloadend = onLoadEndHandler;
  yaml_reader.readAsText(yaml);

  function onLoadEndHandler() {
    self.getFromPhononpyString(yaml_reader.result);
    update();
  }
},

//yaml is the content of "band.yaml" file as a string
getFromPhononpyString = function(yaml) {
  this.k = 0;
  this.n = 0;
  var supercell_lat, rec, lat, nqpoint, npath, phonon, sc_atoms, segment_nqpoint;

  //read the yaml files
  var phononyaml = jsyaml.load(yaml);
  lat      = getYaml('lattice',phononyaml);
  nqpoint  = getYaml('nqpoint',phononyaml);
  npath    = getYaml('npath',phononyaml);
  tmat     = getYaml('supercell_matrix',phononyaml);
  pc_atoms = getYaml('points',phononyaml);
  phonon   = getYaml('phonon',phononyaml);
  if ('segment_nqpoint' in phononyaml) {
    segment_nqpoint = phononyaml['segment_nqpoint'];
  }
  else {
    segment_nqpoint = []
    for (i=0; i<npath; i++) {
      segment_nqpoint.push(nqpoint/npath);
    }
  }

  //get the number of repetitions
  pmat = matrix_multiply(lat,tmat);

  //this will be changed
  nx = 3;
  ny = 3;
  nz = 3;

  //get the atoms inside the unit cell
  var pos,x,y,z,atom_types = [], atom_numbers = [] ;
  var atomic_numbers = {}, pc_atoms_car = [], pc_atoms_red = [];
  for (i=0; i<pc_atoms.length; i++) {
    var symbol = pc_atoms[i]['symbol'];
    var position = pc_atoms[i]['position'];
    atom_numbers.push(atomic_number[symbol]);
    atom_types.push(symbol);
    pc_atoms_red.push(position);
    pc_atoms_car.push(red_car(position,lat));
  }<commit_msg>Fixed compatibility problem when reading band.yaml by looking for a series of possible tags<commit_after>//check if the tags are present and if so return their value 
getYaml = function(tags,object) {
  var ntags = tags.length;
  for (var i = 0; i < ntags; i++) {
      if ((tag in object)) {
        return object[tag];
      }
  }
  alert(tags + " not found in the file! Please generate the file again with the lastest version of phonopy!");
}

//yaml is a file object with the "band.yaml" file
getFromPhononpyFile = function(yaml) {
  var yaml_reader = new FileReader();
  self = this;

  //read the files
  yaml_reader.onloadend = onLoadEndHandler;
  yaml_reader.readAsText(yaml);

  function onLoadEndHandler() {
    self.getFromPhononpyString(yaml_reader.result);
    update();
  }
},

//yaml is the content of "band.yaml" file as a string
getFromPhononpyString = function(yaml) {
  this.k = 0;
  this.n = 0;
  var supercell_lat, rec, lat, nqpoint, npath, phonon, sc_atoms, segment_nqpoint;

  //read the yaml files
  var phononyaml = jsyaml.load(yaml);
  lat      = getYaml({'lattice'},phononyaml);
  nqpoint  = getYaml({'nqpoint'},phononyaml);
  npath    = getYaml({'npath'},phononyaml);
  tmat     = getYaml({'supercell_matrix'},phononyaml);
  pc_atoms = getYaml({'points','atoms'},phononyaml);
  phonon   = getYaml({'phonon'},phononyaml);
  if ('segment_nqpoint' in phononyaml) {
    segment_nqpoint = phononyaml['segment_nqpoint'];
  }
  else {
    segment_nqpoint = []
    for (i=0; i<npath; i++) {
      segment_nqpoint.push(nqpoint/npath);
    }
  }

  //get the number of repetitions
  pmat = matrix_multiply(lat,tmat);

  //this will be changed
  nx = 3;
  ny = 3;
  nz = 3;

  //get the atoms inside the unit cell
  var pos,x,y,z,atom_types = [], atom_numbers = [] ;
  var atomic_numbers = {}, pc_atoms_car = [], pc_atoms_red = [];
  for (i=0; i<pc_atoms.length; i++) {
    var symbol = getYaml({'symbol'},pc_atoms[i]);
    var position = getYaml({'position','coordinates'},pc_atoms[i]);
    atom_numbers.push(atomic_number[symbol]);
    atom_types.push(symbol);
    pc_atoms_red.push(position);
    pc_atoms_car.push(red_car(position,lat));
  }
{'fraction_non_alphanumeric': 0.13644129851110567, 'fraction_numerical': 0.00366121552355382, 'mean_word_length': 3.759581881533101, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '705867', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1474, 'n_words': 350}