public static void getSentence(String input, String output) throws IOException {
   DelimitedWriter dw = new DelimitedWriter(output);
   HashMap<Integer, String> targetArticles = new HashMap<Integer, String>();
   HashCount<String> mid2numSen = new HashCount<String>();
   {
     DelimitedReader dr = new DelimitedReader(input);
     String[] l;
     while ((l = dr.read()) != null) {
       int x = Integer.parseInt(l[1]);
       targetArticles.put(x, l[0]);
     }
     dr.close();
   }
   {
     DelimitedReader dr = new DelimitedReader(Main.file_wiki_sentence + ".tokens");
     String[] l;
     while ((l = dr.read()) != null) {
       String mid = l[1];
       int artid = Integer.parseInt(mid);
       if (targetArticles.containsKey(artid)) {
         // the first sentence of this article
         if (mid2numSen.see(mid) < 5) {
           dw.write(mid, l[3]);
           mid2numSen.add(mid);
         }
       }
     }
     dr.close();
   }
   dw.close();
 }
 public static void getWidOfNobleMen(String input, String output) throws IOException {
   HashMap<String, Integer> mid2wid = new HashMap<String, Integer>();
   {
     DelimitedReader dr = new DelimitedReader(Main.dir_freebase + "/mid2wid");
     String[] l;
     while ((l = dr.read()) != null) {
       mid2wid.put(l[0], Integer.parseInt(l[1]));
     }
     dr.close();
   }
   {
     DelimitedReader dr = new DelimitedReader(input);
     DelimitedWriter dw = new DelimitedWriter(output);
     String[] l;
     while ((l = dr.read()) != null) {
       String mid = l[0];
       Integer wid = mid2wid.get(mid);
       if (wid != null) {
         dw.write(mid, wid);
       }
     }
     dr.close();
     dw.close();
   }
 }
  private static void sampleSql2isntance4DebugPurpose() throws IOException {

    HashMap<Integer, String> wid2title = new HashMap<Integer, String>();
    {
      // load wid 2 title
      DelimitedReader dr = new DelimitedReader(Main.file_gnid_mid_wid_title);

      String[] l;
      while ((l = dr.read()) != null) {
        wid2title.put(Integer.parseInt(l[2]), l[3]);
      }
    }
    HashCount<String> hc = new HashCount<String>();
    {
      DelimitedReader dr = new DelimitedReader(Main.file_sql2instance);
      DelimitedWriter dw = new DelimitedWriter(Main.file_sql2instance + ".sample10");
      String[] l;
      while ((l = dr.read()) != null) {
        String key = l[2] + "\t" + l[3];
        int a = hc.see(key);
        if (a < 10) {
          int wid1 = Integer.parseInt(l[0]);
          int wid2 = Integer.parseInt(l[1]);
          String title1 = wid2title.get(wid1);
          String title2 = wid2title.get(wid2);
          if (title1 != null && title2 != null) {
            dw.write(wid1, wid2, title1, title2, l[2], l[3]);
            hc.add(key);
          }
        }
      }
      dw.close();
      dr.close();
    }
  }
 static void step2() throws IOException {
   {
     HashMap<String, String[]> mid2other = new HashMap<String, String[]>();
     DelimitedWriter dw = new DelimitedWriter(file_targetrelation + ".2");
     {
       DelimitedReader dr = new DelimitedReader(Main.file_mid2typename);
       String[] l;
       while ((l = dr.read()) != null) {
         String mid = l[0];
         mid2other.put(mid, l);
       }
       dr.close();
     }
     {
       DelimitedReader dr = new DelimitedReader(file_targetrelation + ".1");
       String[] l;
       HashSet<String> avoidduplicate = new HashSet<String>();
       while ((l = dr.read()) != null) {
         String mid1 = l[1];
         String mid2 = l[3];
         String[] info1 = mid2other.get(mid1);
         String[] info2 = mid2other.get(mid2);
         if (!avoidduplicate.contains(mid1 + "\t" + mid2)
             && info1 != null
             && info2 != null
             && !mid1.equals(mid2)) {
           dw.write(mid1, mid2, info1[3], info2[3], info1[2], info2[2]);
           avoidduplicate.add(mid1 + "\t" + mid2);
         }
       }
       dr.close();
     }
     dw.close();
   }
   {
     HashSet<String> typeOfArg2 = new HashSet<String>();
     List<String[]> all = (new DelimitedReader(file_targetrelation + ".2")).readAll();
     for (String[] a : all) {
       typeOfArg2.add(a[5]);
     }
     for (String a : typeOfArg2) {
       D.p(a);
     }
   }
 }
 public static void getAllNobleMen(String output) throws IOException {
   DelimitedReader dr = new DelimitedReader(Main.dir_freebase + "/visible");
   DelimitedWriter dw = new DelimitedWriter(output);
   String[] l;
   /// j0	/m/04l4q52	/type/type/instance	/m/02rg_
   while ((l = dr.read()) != null) {
     if (l[1].equals(MIDOFNOBLEPERSON) && l[2].equals("/type/type/instance")) {
       dw.write(l[3]);
     }
   }
   dr.close();
   dw.close();
 }
 static void step1() throws IOException {
   Set<String> usedrel = new HashSet<String>();
   for (String r : mappedrelation) usedrel.add(r);
   DelimitedReader dr = new DelimitedReader(Main.file_fbvisibledump);
   DelimitedWriter dw = new DelimitedWriter(file_targetrelation + ".1");
   String[] l;
   while ((l = dr.read()) != null) {
     if (usedrel.contains(l[2])) {
       dw.write(l);
     }
   }
   dr.close();
   dw.close();
 }