Example #1
0
  public void createWordLists() {
    try {
      crsOperation.wordArrayForTrain = ChordType.getStringValues();
      FileWriter fileWriter = new FileWriter(HelperFile.getFile(crsOperation.wordListTrainPath));
      for (String chord : crsOperation.wordArrayForTrain) {
        fileWriter.write(chord + "\n");
      }
      fileWriter.close();
    } catch (IOException e) {
      logger.error("Problems: ");
      logger.error(Helper.getStackTrace(e));
    }

    try {
      FileWriter fileWriter = new FileWriter(HelperFile.getFile(crsOperation.wordListTestPath));
      FileWriter fileWriterLM = new FileWriter(HelperFile.getFile(crsOperation.wordListLMPath));

      for (ChordType modality : ChordType.chordDictionary) {
        if (!modality.equals(ChordType.NOT_A_CHORD)) {
          for (Root root : Root.values()) {
            fileWriter.write(String.format("%s%s\n", root, modality));
            fileWriterLM.write(String.format("%s%s\n", root, modality));
          }
        } else {
          if (Arrays.asList(ChordType.chordDictionary).contains(ChordType.NOT_A_CHORD)) {
            fileWriter.write(ChordType.NOT_A_CHORD.getName() + "\n");
            fileWriterLM.write(ChordType.NOT_A_CHORD.getName() + "\n");
          }
        }
      }
      fileWriterLM.write(LabelsParser.START_SENTENCE + "\n");
      fileWriterLM.write(LabelsParser.END_SENTENCE + "\n");

      fileWriter.close();
      fileWriterLM.close();
    } catch (IOException e) {
      logger.error("Problems: ");
      logger.error(Helper.getStackTrace(e));
    }
  }
Example #2
0
 protected void createMLFOneModel() {
   try {
     FileWriter fileWriter = new FileWriter(HelperFile.getFile(crsOperation.mlfFilePath));
     fileWriter.write("#!MLF!#\n");
     for (ChordType modality : ChordType.chordDictionary) {
       fileWriter.write(String.format("\"*.lab\"\n%s\n.\n", modality.getName()));
     }
     fileWriter.close();
   } catch (IOException e) {
     logger.error("Problems: ");
     logger.error(Helper.getStackTrace(e));
   }
 }
Example #3
0
 public void createDictionaryFile() {
   try {
     FileWriter writer = new FileWriter(HelperFile.getFile(crsOperation.dictFilePath));
     for (ChordType modality : ChordType.chordDictionary) {
       if (!modality.equals(ChordType.NOT_A_CHORD)) {
         for (Root root : Root.values()) {
           writer.write(String.format("%s%s %s%s\n", root, modality, root, modality));
         }
       }
       if (Arrays.asList(ChordType.chordDictionary).contains(ChordType.NOT_A_CHORD)) {
         writer.write(String.format("%s %s\n", ChordType.NOT_A_CHORD, ChordType.NOT_A_CHORD));
       }
     }
     writer.close();
   } catch (IOException e) {
     logger.error("Problems: ");
     logger.error(Helper.getStackTrace(e));
   }
 }
Example #4
0
  @Test(dataProvider = "testData")
  public void testCreateFLMSpec(String directory, int maxNumberOfWords, int maxNumberOfDurations)
      throws Exception {
    HelperFile.createDir(directory);

    BufferedWriter writer =
        new BufferedWriter(new FileWriter(String.format("%s/summary.txt", directory)));
    String filePath;
    for (int i = 1; i <= maxNumberOfWords; i++) {
      for (int j = 0; j <= maxNumberOfDurations; j++) {
        filePath = String.format("%s/%d_%d.flm", directory, i, j);
        FLMSpecification.createFLMSpec(filePath, i, j);
        //                Helper.execCmd("D:\\temp\\script\\FLMTrain\\traintest.bat " + filePath,
        // writer);
        writer.write("It was FLM : W = " + i + " , D = " + j + "\n");
        writer.write("------------------------------------------\n");
      }
    }

    writer.close();
  }