Пример #1
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));
   }
 }
Пример #2
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));
    }
  }