コード例 #1
0
ファイル: Bot.java プロジェクト: dims12/program-ab
 /** Load all AIML Maps */
 int addAIMLMaps() {
   int cnt = 0;
   Timer timer = new Timer();
   timer.start();
   try {
     // Directory path here
     String file;
     File folder = new File(maps_path);
     if (folder.exists()) {
       File[] listOfFiles = IOUtils.listFiles(folder);
       if (MagicBooleans.trace_mode)
         System.out.println("Loading AIML Map files from " + maps_path);
       for (File listOfFile : listOfFiles) {
         if (listOfFile.isFile()) {
           file = listOfFile.getName();
           if (file.endsWith(".txt") || file.endsWith(".TXT")) {
             if (MagicBooleans.trace_mode) System.out.println(file);
             String mapName = file.substring(0, file.length() - ".txt".length());
             if (MagicBooleans.trace_mode) System.out.println("Read AIML Map " + mapName);
             AIMLMap aimlMap = new AIMLMap(mapName, this);
             cnt += aimlMap.readAIMLMap(this);
             mapMap.put(mapName, aimlMap);
           }
         }
       }
     } else System.out.println("addAIMLMaps: " + maps_path + " does not exist.");
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return cnt;
 }
コード例 #2
0
  /** Load all AIML Maps */
  int addAIMLMaps() {
    int cnt = 0;
    Timer timer = new Timer();
    timer.start();

    try {
      String[] listOfFiles = Alice.getContext().getAssets().list(maps_path);
      if (MagicBooleans.trace_mode) {
        System.out.println("Loading AIML Map files from " + maps_path);
        BrainLogger.getInstance().info("Loading AIML Map files from " + maps_path);
      }

      for (String file : listOfFiles) {

        if (file.endsWith(".txt") || file.endsWith(".TXT")) {
          if (MagicBooleans.trace_mode) System.out.println(file);
          String mapName = file.substring(0, file.length() - ".txt".length());
          if (MagicBooleans.trace_mode) System.out.println("Read AIML Map " + mapName);
          AIMLMap aimlMap = new AIMLMap(mapName, this);
          cnt += aimlMap.readAIMLMap(this);
          mapMap.put(mapName, aimlMap);
        }
      }
    } catch (IOException e) {
      System.out.println("addAIMLMaps: " + maps_path + " does not exist.");
      e.printStackTrace();
    }

    return cnt;
  }