コード例 #1
0
ファイル: PhonexMatchNode.java プロジェクト: phon-ca/phon
  /** Updates outputs based on current pattern's group settings. */
  private void updateOutputs() {
    for (int i = 1; i <= pattern.numberOfGroups(); i++) {
      // try to find output field
      int outputFieldIdx = i + 1;
      final String outName = (pattern.groupName(i) != null ? pattern.groupName(i) : "g" + i);
      OutputField outField = null;
      if (outputFieldIdx < getOutputFields().size()) {
        outField = getOutputFields().get(outputFieldIdx);
      } else {
        outField = new OutputField(outName, "output for group " + i, false, IPATranscript.class);
        putField(outField);
      }
      outField.setKey(outName);
    }

    // remove extras
    for (int i = pattern.numberOfGroups() + 2; i < getOutputFields().size(); i++) {
      removeField(getOutputFields().get(i));
    }

    //		// add a new output field for each group
    //		// in our pattern
    //		for(int gIdx = 1; gIdx <= pattern.numberOfGroups(); gIdx++) {
    //			String outputName =
    //					(pattern.groupName(gIdx) != null ? pattern.groupName(gIdx) : "g" + gIdx);
    //			OutputField groupOut =
    //					new OutputField(outputName, "Content of group " + gIdx + ". Valid only if matches is
    // true",
    //							false, IPATranscript.class);
    //			super.putField(groupOut);
    //		}
  }
コード例 #2
0
ファイル: PhonexMatchNode.java プロジェクト: phon-ca/phon
 @Override
 public Properties getSettings() {
   final Properties retVal = new Properties();
   if (pattern != null) {
     retVal.setProperty(PHONEX_KEY, pattern.pattern());
   }
   return retVal;
 }
コード例 #3
0
ファイル: PhonexMatchNode.java プロジェクト: phon-ca/phon
  @Override
  public void operate(OpContext arg0) throws ProcessingException {
    // get input
    IPATranscript transcript = IPATranscript.class.cast(arg0.get(ipaInput));

    // create a new matcher
    PhonexMatcher matcher = pattern.matcher(transcript);
    if (matcher.matches()) {
      // set matches output
      arg0.put(matchesOut, Boolean.TRUE);

      arg0.put(g0Out, new IPATranscript(matcher.group(0)));

      for (int gIdx = 1; gIdx <= pattern.numberOfGroups(); gIdx++) {
        String outputName =
            (pattern.groupName(gIdx) != null ? pattern.groupName(gIdx) : "g" + gIdx);
        arg0.put(outputName, new IPATranscript(matcher.group(gIdx)));
      }
    }
  }
コード例 #4
0
ファイル: PhonexMatchNode.java プロジェクト: phon-ca/phon
 /**
  * Set (and compile) phonex expression.
  *
  * @param phonex
  * @throws PhonexPatternException if the given phonex is not valid
  */
 @Override
 public void setPhonex(String phonex) throws PhonexPatternException {
   pattern = PhonexPattern.compile(phonex);
   if (pattern != null) updateOutputs();
 }
コード例 #5
0
ファイル: PhonexMatchNode.java プロジェクト: phon-ca/phon
 @Override
 public String getPhonex() {
   String retVal = "";
   if (pattern != null) retVal = pattern.pattern();
   return retVal;
 }