Example #1
0
  public void loadDataset(String fileName, int maxCount) {

    // Clearing the database
    if (database == null) {
      database = new SequenceDatabase();
    } else {
      database.clear();
    }

    // Tries to guess the format if it is a predefined dataset
    try {

      Format datasetFormat = Format.valueOf(fileName);
      loadPredefinedDataset(datasetFormat, maxCount);

    } catch (IllegalArgumentException e) {
      loadCustomDataset(fileName, maxCount);
    }

    // Shuffling the database
    Collections.shuffle(database.getSequences());
  }
Example #2
0
  private void loadCustomDataset(String fileName, int maxCount) {
    try {

      database.loadFileCustomFormat(
          fileToPath(fileName),
          maxCount,
          Profile.paramInt("sequenceMinSize"),
          Profile.paramInt("sequenceMaxSize"));

    } catch (IOException e) {
      System.out.println("Could not load dataset, IOExeption");
      e.printStackTrace();
    }
  }
Example #3
0
  /** Loads a predefined dataset -- see full list in DatabaseHelper.Format */
  private void loadPredefinedDataset(Format format, int maxCount) {

    // Loading the specified dataset (according to the format)
    try {
      switch (format) {
        case BMS:
          database.loadFileBMSFormat(
              fileToPath("BMS.dat"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case KOSARAK:
          database.loadFileCustomFormat(
              fileToPath("kosarak.dat"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case FIFA:
          database.loadFileFIFAFormat(
              fileToPath("FIFA_large.dat"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case MSNBC:
          database.loadFileMsnbsFormat(
              fileToPath("msnbc.seq"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case SIGN:
          database.loadFileSignLanguage(
              fileToPath("sign_language.txt"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case CANADARM1:
          database.loadFileSPMFFormat(
              fileToPath("Canadarm1_actions.txt"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case CANADARM2:
          database.loadFileSPMFFormat(
              fileToPath("Canadarm2_states.txt"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case SNAKE:
          database.loadSnakeDataset(
              fileToPath("snake.dat"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case BIBLE_CHAR:
          database.loadFileLargeTextFormatAsCharacter(
              fileToPath("Bible.txt"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"));
          break;
        case BIBLE_WORD:
          database.loadFileLargeTextFormatAsWords(
              fileToPath("Bible.txt"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"),
              true);
          break;
        case KORAN_WORD:
          database.loadFileLargeTextFormatAsWords(
              fileToPath("koran.txt"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"),
              false);
          break;
        case LEVIATHAN_WORD:
          database.loadFileLargeTextFormatAsWords(
              fileToPath("leviathan.txt"),
              maxCount,
              Profile.paramInt("sequenceMinSize"),
              Profile.paramInt("sequenceMaxSize"),
              false);
          break;
        default:
          System.out.println("Could not load dataset, unknown format.");
      }

    } catch (IOException e) {
      System.out.println("Could not load dataset, IOExeption");
      e.printStackTrace();
    }
  }