Пример #1
0
 /** Load all AIML Sets */
 int addAIMLSets() {
   int cnt = 0;
   Timer timer = new Timer();
   timer.start();
   try {
     // Directory path here
     String file;
     File folder = new File(sets_path);
     if (folder.exists()) {
       File[] listOfFiles = IOUtils.listFiles(folder);
       if (MagicBooleans.trace_mode)
         System.out.println("Loading AIML Sets files from " + sets_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 setName = file.substring(0, file.length() - ".txt".length());
             if (MagicBooleans.trace_mode) System.out.println("Read AIML Set " + setName);
             AIMLSet aimlSet = new AIMLSet(setName, this);
             cnt += aimlSet.readAIMLSet(this);
             setMap.put(setName, aimlSet);
           }
         }
       }
     } else System.out.println("addAIMLSets: " + sets_path + " does not exist.");
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return cnt;
 }