Example #1
0
 public String instantiateSets(String pattern) {
   String[] splitPattern = pattern.split(" ");
   pattern = "";
   for (String x : splitPattern) {
     if (x.startsWith("<SET>")) {
       String setName = AIMLProcessor.trimTag(x, "SET");
       AIMLSet set = setMap.get(setName);
       if (set != null) x = "FOUNDITEM";
       else x = "NOTFOUND";
     }
     pattern = pattern + " " + x;
   }
   return pattern.trim();
 }
Example #2
0
 /** Load all brain categories from AIML directory */
 int addCategoriesFromAIML() {
   Timer timer = new Timer();
   timer.start();
   int cnt = 0;
   try {
     // Directory path here
     String file;
     File folder = new File(aiml_path);
     if (folder.exists()) {
       File[] listOfFiles = IOUtils.listFiles(folder);
       if (MagicBooleans.trace_mode) System.out.println("Loading AIML files from " + aiml_path);
       for (File listOfFile : listOfFiles) {
         if (listOfFile.isFile()) {
           file = listOfFile.getName();
           if (file.endsWith(".aiml") || file.endsWith(".AIML")) {
             if (MagicBooleans.trace_mode) System.out.println(file);
             try {
               ArrayList<Category> moreCategories =
                   AIMLProcessor.AIMLToCategories(aiml_path, file);
               addMoreCategories(file, moreCategories);
               cnt += moreCategories.size();
             } catch (Exception iex) {
               System.out.println("Problem loading " + file);
               iex.printStackTrace();
             }
           }
         }
       }
     } else System.out.println("addCategoriesFromAIML: " + aiml_path + " does not exist.");
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   if (MagicBooleans.trace_mode)
     System.out.println("Loaded " + cnt + " categories in " + timer.elapsedTimeSecs() + " sec");
   return cnt;
 }