Пример #1
0
  // test
  public static void main(String[] args) {
    String vers = "3.0";
    String wnhome = "C:/Program Files/WordNet/" + vers + "/dict";
    String icfile =
        "C:/Program Files/WordNet/" + vers + "/WordNet-InfoContent-" + vers + "/ic-semcor.dat";
    URL url = null;
    try {
      url = new URL("file", null, wnhome);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }
    if (url == null) {
      return;
    }
    IDictionary dict = new Dictionary(url);
    try {
      dict.open();
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    ICFinder icfinder = new ICFinder(icfile);
    DepthFinder depthfinder = new DepthFinder(dict, icfile);
    double depth1 = depthfinder.getSynsetDepth("opposition", 2, "n");
    System.out.println(depth1);
  }
Пример #2
0
 static {
   dict = null;
   String wnhome = System.getenv("WNHOME");
   String path =
       (new StringBuilder(String.valueOf(wnhome)))
           .append(File.separator)
           .append("dict")
           .toString();
   System.out.println(
       (new StringBuilder("Path to dictionary:")).append(getWNLocation()).toString());
   URL url = null;
   try {
     File f =
         new File(
             (new StringBuilder(String.valueOf(getWNLocation())))
                 .append(File.separator)
                 .append("dict")
                 .toString());
     URI uri = f.toURI();
     url = uri.toURL();
   } catch (MalformedURLException e) {
     e.printStackTrace();
   }
   dict = new Dictionary(url);
   dict.open();
 }