示例#1
0
  private void setNeighborSylOfSyllable() {

    // luu y truong hop dau phrase, dau sentence, dau file
    // kiem tra xem co phai la dau phrase hay ko; neu am tiet dau co id = 0 thi la dau phrase
    for (int i = 0; i < this.getAllSentences().size(); i++) {
      Sentence sent = this.getAllSentences().get(i);
      ArrayList<SylPhrase> sylPhrasesInSent = sent.getSylPhrases();
      for (int j = 0; j < sylPhrasesInSent.size(); j++) {
        SylPhrase oneSylPharse = sylPhrasesInSent.get(j);
        ArrayList<Syllable> syllablesInPh = oneSylPharse.getSyllablesInPh();
        for (int k = 0; k < syllablesInPh.size(); k++) {
          if (k == 0) {}
        }
      }
    }
  }
示例#2
0
  @Override
  public void ReadDetails() {
    try {
      while (xMLStreamReader.hasNext()) {
        Integer eventType = xMLStreamReader.next();
        //                if (eventType.equals(XMLEvent.START_ELEMENT)) {
        //                    System.out.println("START_ELEMENT " + xMLStreamReader.getName() + " "
        // + xMLStreamReader.getAttributeCount());
        //                } else if (eventType.equals(XMLEvent.CHARACTERS)) {
        //                    System.out.println("CHARACTERS " + xMLStreamReader.getText() + " ");
        //                    //ko thay in ra gi
        if (eventType.equals(XMLEvent.START_ELEMENT)) {
          // neu eventType =  START_ELEMENT thi kiem tra, neu Name = File thi ReadFile,
          //      neu Name = root thi bo qua, neu Name = Syllable thi ReadSyl
          // neu eventType = CHARACTERS thi bo qua
          // neu eventType = END_ELEMENT thi kiem tra, neu Name = Syllable thi bo qua
          //      neu Name = File thi ket thuc file
          //      neu Name = sentence thi ket thuc cau
          nameOfElement = xMLStreamReader.getName().toString();
          if (nameOfElement.compareTo("file") == 0) {
            ReadFileDetails();
          } else if (nameOfElement.compareTo("sentence") == 0) {
            ReadSentenceDetails();
          } else if (nameOfElement.compareTo("phrase") == 0) {
            ReadPhraseDetails();
          } else if (nameOfElement.compareTo("syllable") == 0) {
            ReadSylDetails();
          } else if (nameOfElement.compareTo("initial") == 0) {
            syllable.setInitialType(xMLStreamReader.getAttributeValue(0));
            syllable.setIntialPhoneme(xMLStreamReader.getElementText());

          } else if (nameOfElement.compareTo("middle") == 0) {
            syllable.setMiddleType(xMLStreamReader.getAttributeValue(0));
            syllable.setMiddlePhoneme(xMLStreamReader.getElementText());
          } else if (nameOfElement.compareTo("nucleus") == 0) {
            syllable.setNucleusType(xMLStreamReader.getAttributeValue(0));
            syllable.setNucleusPhoneme(xMLStreamReader.getElementText());
          } else if (nameOfElement.compareTo("final") == 0) {
            syllable.setFinalType(xMLStreamReader.getAttributeValue(0));
            syllable.setFinalPhoneme(xMLStreamReader.getElementText());
          } else if (nameOfElement.compareTo("leftSyl") == 0) {
            readLeftSylDetails();

          } else if (nameOfElement.compareTo("rightSyl") == 0) {
            readRightSylDetails();

          } else if (nameOfElement.compareTo("tone") == 0) {
            syllable.setSylTone(StrToInt(xMLStreamReader.getElementText()));
          } else if (nameOfElement.compareTo("root") == 0) {
            continue;
          } else {
            System.out.println("DON'T KNOW THIS START_ELEMENT");
          }
        } else if (eventType.equals(XMLEvent.END_ELEMENT)) {
          nameOfElement = xMLStreamReader.getName().toString();
          if (nameOfElement.compareTo("leftSyl") == 0) {
          } else if (nameOfElement.compareTo("rightSyl") == 0) {
          } else if (nameOfElement.compareTo("syllable") == 0) {
            phrase.getSyllablesInPh().add(syllable);
          } else if (nameOfElement.compareTo("phrase") == 0) {
            phrase.setContent();
            phrase.setPhraseLen();
            sentence.getSylPhrases().add(phrase);
          } else if (nameOfElement.compareTo("sentence") == 0) {
            sentence.setSenContent();
            getAllSentences().add(sentence);
          }
        } else if (eventType.equals(XMLEvent.CHARACTERS)) {
          // System.out.println("Characters");
          continue;
        } else if (eventType.equals(XMLEvent.END_DOCUMENT)) {
          continue;
        } else {
          System.out.println(eventType);
          System.out.println("DON'T KNOW THIS EVENT");
        }
      }
    } catch (XMLStreamException ex) {
      Logger.getLogger(XMLTextDBSylReader.class.getName()).log(Level.SEVERE, null, ex);
    }
    try {
      xMLStreamReader.close();
    } catch (XMLStreamException ex) {
      Logger.getLogger(XMLTextDBSylReader.class.getName()).log(Level.SEVERE, null, ex);
    }
    ////////////////////////////////////////////////////////////////////////
    // System.out.println("so luong cau: " + this.getAllSentences().size());
  }
示例#3
0
 public void ReadPhraseDetails() {
   phrase = new SylPhrase();
   phrase.setId_phrase(StrToInt(xMLStreamReader.getAttributeValue(0)));
   phrase.setPhraseLen(StrToInt(xMLStreamReader.getAttributeValue(1)));
 }