Package simplenlg.features

Examples of simplenlg.features.Inflection


      } else if (word instanceof WordElement) {
        WordElement we = (WordElement) word;

        // Inflection
        if (wordElement.getVar() != null) {
          Inflection defaultInflection = Enum.valueOf(
              Inflection.class, wordElement.getVar().toString());
          we.setDefaultInflectionalVariant(defaultInflection);
        }

        // Spelling variant may have been given as base form in xml.
View Full Code Here


      addVerbInfo(wordElement, record.GetCatEntry().GetVerbEntry());
      break;
    // ignore closed class words
    }

    Inflection defaultInfl = (Inflection) wordElement
        .getDefaultInflectionalVariant();

    // now add inflected forms
    // if (keepStandardInflections || !standardInflections(record,
    // category)) {
    for (InflVar inflection : record.GetInflVarsAndAgreements()
        .GetInflValues()) {
      String simplenlgInflection = getSimplenlgInflection(inflection
          .GetInflection());

      if (simplenlgInflection != null) {
        String inflectedForm = inflection.GetVar();
        Inflection inflType = Inflection.getInflCode(inflection
            .GetType());

        // store all inflectional variants, except for regular ones
        // unless explicitly set
        if (inflType != null
View Full Code Here

        } else {
          code = v.toLowerCase().trim();
        }

        Inflection infl = Inflection.getInflCode(code);

        if (infl != null) {
          wordVariants.add(infl);
          wordElement.addInflectionalVariant(infl);
        }
      }

      // if the variants include "reg", this is the default, otherwise
      // just a random pick
      Inflection defaultVariant = wordVariants
          .contains(Inflection.REGULAR)
          || wordVariants.isEmpty() ? Inflection.REGULAR
          : wordVariants.get(0);     
      wordElement.setFeature(LexicalFeature.DEFAULT_INFL, defaultVariant);
      wordElement.setDefaultInflectionalVariant(defaultVariant);
View Full Code Here

      List<Inflection> wordVariants = new ArrayList<Inflection>();

      for (String v : variants) {
        int index = v.indexOf("|");
        String code;
        Inflection infl;

        if (index > -1) {
          code = v.substring(0, index).toLowerCase().trim();
          infl = Inflection.getInflCode(code);         

        } else {
          infl = Inflection.getInflCode(v.toLowerCase().trim());
        }

        if (infl != null) {
          wordElement.addInflectionalVariant(infl);
          wordVariants.add(infl);
        }
      }

      // if the variants include "reg", this is the default, otherwise
      // just a random pick
      Inflection defaultVariant = wordVariants
          .contains(Inflection.REGULAR)
          || wordVariants.isEmpty() ? Inflection.REGULAR
          : wordVariants.get(0);
//      wordElement.setFeature(LexicalFeature.INFLECTIONS, wordVariants);
//      wordElement.setFeature(LexicalFeature.DEFAULT_INFL, defaultVariant);
View Full Code Here

        else if (feature.equalsIgnoreCase(XML_ID))
          word.setId(value);

        else if (value == null || value.equals("")) {
          // if this is an infl code, add it to inflections
          Inflection infl = Inflection.getInflCode(feature);

          if (infl != null) {
            inflections.add(infl);
          } else {
            // otherwise assume it's a boolean feature
            word.setFeature(feature, true);
          }
        } else
          word.setFeature(feature, value);
      }

    }

    // if no infl specified, assume regular
    if (inflections.isEmpty()) {
      inflections.add(Inflection.REGULAR);
    }

    // default inflection code is "reg" if we have it, else random pick form
    // infl codes available
    Inflection defaultInfl = inflections.contains(Inflection.REGULAR) ? Inflection.REGULAR
        : inflections.get(0);   
   
    word.setFeature(LexicalFeature.DEFAULT_INFL, defaultInfl);
    word.setDefaultInflectionalVariant(defaultInfl);
   
View Full Code Here

TOP

Related Classes of simplenlg.features.Inflection

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.