private void getContextFromFile()

in geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContextGenerator.java [290:331]


  private void getContextFromFile(File countryContextFile) {
    if (this.adminBoundaryData != null && !this.adminBoundaryData.isEmpty()) {
      return;
    }

    BufferedReader reader;
    try {
      reader = new BufferedReader(new FileReader(countryContextFile));
      String line;
      int lineNum = 0;
      while ((line = reader.readLine()) != null) {
        String[] values = line.split("\t");
        if (lineNum == 0) {
          lineNum++;
          continue;
          //skip column name headers
        }
        if (values.length == 9) {
          AdminBoundary entry = new AdminBoundary(
              values[0].toLowerCase().trim().replace("", ""),
              values[3].toLowerCase().trim(),
              values[1].toLowerCase().trim(),
              values[4].toLowerCase().trim(),
              values[2].toLowerCase().trim(),
              values[5].toLowerCase().trim(),
              values[6].toLowerCase().trim(),
              values[7].toLowerCase().trim(),
              values[8].toLowerCase().trim());
          this.adminBoundaryData.add(entry);
        } else {
          throw new IllegalArgumentException("Improperly formatted file");
        }

      }
      reader.close();
    } catch (IOException ex) {
      LOG.error(ex.getLocalizedMessage(), ex);
    }

    loadMaps(this.adminBoundaryData);

  }