package org.plenix.translator;

public abstract class TranslatorImpl implements Translator {
  public String getTermType(String referenceTerm, String languageCode)
    throws TranslatorException
  {
    String termType = getTermType(referenceTerm);

    if (termType == null) {
      return null;
    }

    String[] terms = translate(termType, languageCode);

    if (terms == null) {
      return null;
    }

    return terms[0];
  }

  public String getTermType(String referenceTerm) {
    char endLetter = referenceTerm.charAt(referenceTerm.length() - 1);

    switch (endLetter) {
      case 'o':
        return "substantivo";
      case 'a':
        return "adjektivo";
      case 'e':
        return "adverbo";
      case 'i':
        return "verbo";
      default:
        return null;
    }
  }
}