Package grammar.model

Examples of grammar.model.WordMatcher


      affectedSegments.add(Segment.valueOf(parsedStringAsConstant));
    }
    else if (parseMode == ParseMode.MATCH_TYPE) {
      disableParsing();
      if (infinitiveContext)
        matchTypes.add(new WordMatcher(matchType, parsedString));
      else if (auxiliaryOfContext)
        infinitiveMatchers.add(new WordMatcher(auxiliaryMatchType, parsedString));
    }
    else if (parseMode == ParseMode.PARENT) {
      disableParsing();
      try {
        ModelVerb p = ModelVerb.valueOf(getLanguage(), parsedString);
View Full Code Here


    }
    else if (mode.equals(ParseMode.SEQUENCE)) {
      sequence = Integer.parseInt(str);
    }
    else if (mode.equals(ParseMode.RULE)) {
      nounMatchers.add(new WordMatcher(matchType, str));
    }
    disableParsing();
  }
View Full Code Here

    //System.err.println("ModelVerb.isCloserMatch():"+new Date());

    if (isDescendantOf(other))
      return true;

    WordMatcher infinitiveMatcher;
    try {
      infinitiveMatcher = getInfinitiveMatcher(infinitive, reflexive);
    }
    catch (IllegalArgumentException iae) {
      return false;
    }

    WordMatcher otherMatcher;
    try {
      otherMatcher = other.getInfinitiveMatcher(infinitive, reflexive);
    }
    catch (IllegalArgumentException iae) {
      return true;
    }

    if ((infinitiveMatcher.getMatchType() == MatchType.PATTERN || infinitiveMatcher.getMatchType() == MatchType.SUFFIX) &&
        (otherMatcher.getMatchType() == MatchType.PATTERN || otherMatcher.getMatchType() == MatchType.SUFFIX)) {
      return getMatchStringPointsValue(infinitiveMatcher) >
        getMatchStringPointsValue(otherMatcher);
    }
    if (infinitiveMatcher.getMatchType() != otherMatcher.getMatchType())
      return infinitiveMatcher.getMatchType().ordinal() > otherMatcher.getMatchType().ordinal();
    return false;
  }
View Full Code Here

    @Override
    public String getHintText() {
      StringBuilder sb = new StringBuilder();
     
      WordMatcher wm = nf.getNounClassMatcher();
      String f = null;
      if (wm != null) {
        if (wm.getMatchType().equals(MatchType.SUFFIX))
          f = "ends with";
        else
          throw new Error("implement me"); // TODO
      }
     
      if (nf.isRegular()) {
        sb.append("Note: "+nf.getText()+" follows a pattern for "+
            Utilities.asHumanReadableName(nf.getNounClasses().get(0).getName())+
            " nouns, as it "+f+" "+wm.getMatchString()+".");
      }
      else if (wm == null) {
        sb.append("Note: "+nf.getText()+"'s gender is irregular - it doesn't end with any suffix reliably associated with a noun class.");
      }
      else if (nf.getNounClasses().size() > 1) {
        // do nothing
      }
      else {
        sb.append("Note: "+nf.getText()+
            "'s gender is irregular - typically, nouns ending with "+
            wm.getMatchString()+" are "+Utilities.asHumanReadableName(
                NounClassFactory.getInstance(getLanguage()).getClosestMatch(nf.getText()).getName())+".");
      }
     
      return sb.toString();
    }
View Full Code Here

    }
    throw new IllegalArgumentException("Word does not match this gender.");
  }

  public boolean isCloserMatch(String infinitive, NounClass other) {
    WordMatcher infinitiveMatcher = getNounMatcher(infinitive);
    WordMatcher otherMatcher = other.getNounMatcher(infinitive);
    if ((infinitiveMatcher.getMatchType() == MatchType.PATTERN || infinitiveMatcher.getMatchType() == MatchType.SUFFIX) &&
        (otherMatcher.getMatchType() == MatchType.PATTERN || otherMatcher.getMatchType() == MatchType.SUFFIX)) {
      return getMatchStringPointsValue(infinitiveMatcher) >
        getMatchStringPointsValue(otherMatcher);
    }
    if (infinitiveMatcher.getMatchType() != otherMatcher.getMatchType())
      return infinitiveMatcher.getMatchType().ordinal() > otherMatcher.getMatchType().ordinal();
    return false;
  }
View Full Code Here

TOP

Related Classes of grammar.model.WordMatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.