Ejemplo n.º 1
1
 public String formatNoEmpty() {
   StringBuilder sb = new StringBuilder("[(").append(dictionaryItem.lemma).append(") ");
   for (InflectionalGroup ig : inflectionalGroups) {
     sb.append(ig.formatNoEmpty());
   }
   sb.append("]");
   return sb.toString();
 }
Ejemplo n.º 2
0
 public String formatOnlyIgs() {
   StringBuilder sb = new StringBuilder();
   for (InflectionalGroup ig : inflectionalGroups) {
     sb.append(ig.formatNoSurface());
   }
   return sb.toString();
 }
Ejemplo n.º 3
0
  public MorphParse(StemNode stemNode, List<SuffixSurfaceNode> suffixSurfaceNodes) {
    this.dictionaryItem = stemNode.getDictionaryItem();
    this.root = stemNode.surfaceForm;

    InflectionalGroup ig = new InflectionalGroup();
    List<InflectionalGroup> igs = Lists.newArrayListWithCapacity(2);
    ig.pos = dictionaryItem.primaryPos;
    ig.spos = dictionaryItem.secondaryPos;
    int j = 0;
    for (SuffixSurfaceNode suffixNode : suffixSurfaceNodes) {

      SuffixFormTemplate template = null;
      if (suffixNode.getSuffixForm() instanceof NullSuffixForm) {
        template = ((NullSuffixForm) suffixNode.getSuffixForm()).getTemplate();
      }

      // if node is a derivational node then we create a new ig and store the other
      if (template != null && (template instanceof DerivationalSuffixTemplate || j == 0)) {
        RootSuffix rootSuffix = (RootSuffix) template.getSuffix();
        if (ig.pos == null) {
          ig.pos = rootSuffix.pos;
        }
        if (j > 0) {
          igs.add(ig);
          ig = new InflectionalGroup();
          ig.pos = rootSuffix.pos;
        }

      } else {
        if (!(suffixNode.getSuffixForm().getSuffix() instanceof RootSuffix))
          ig.suffixList.add(
              new SuffixData(
                  suffixNode.getSuffixForm().suffix,
                  suffixNode.surfaceForm,
                  suffixNode.getSuffixForm().generation));
      }
      j++;
    }
    if (igs.isEmpty() || !ig.suffixList.isEmpty()) {
      igs.add(ig);
    }
    this.inflectionalGroups = igs;
  }
Ejemplo n.º 4
0
 /**
  * Returns surface forms list of all root and derivational roots of a parse. Examples: "kitaplar"
  * ->["kitap"] "kitabım" ->["kitab"] "kitaplaşır"->["kitap", "kitaplaş"] "kavrulduk" ->
  * ["kavr","kavrul"]
  */
 public List<String> getStems() {
   List<String> stems = Lists.newArrayListWithCapacity(2);
   stems.add(root);
   String previousStem = stems.get(0);
   if (inflectionalGroups.size() > 1) {
     previousStem = previousStem + inflectionalGroups.get(0).surfaceForm();
     for (int i = 1; i < inflectionalGroups.size(); i++) {
       InflectionalGroup ig = inflectionalGroups.get(i);
       SuffixData suffixData = ig.suffixList.get(0);
       if (suffixData.surface.length() > 0) {
         String surface = suffixData.surface;
         String stem = previousStem + surface;
         if (!stems.contains(stem)) stems.add(stem);
       }
       previousStem = previousStem + ig.surfaceForm();
     }
   }
   return stems;
 }
Ejemplo n.º 5
0
 /**
  * Returns list of all lemmas of a parse. Examples: "kitaplar" ->["kitap"] "kitabım" ->["kitap"]
  * "kitaplaşır"->["kitap", "kitaplaş"] "kitaplaş" ->["kitap", "kitaplaş"] "arattıragörür" ->
  * ["ara","arat","arattır","arattıragör"]
  */
 public List<String> getLemmas() {
   List<String> lemmas = Lists.newArrayListWithCapacity(2);
   lemmas.add(dictionaryItem.root);
   String previousStem = root;
   if (inflectionalGroups.size() > 1) {
     previousStem = previousStem + inflectionalGroups.get(0).surfaceForm();
     for (int i = 1; i < inflectionalGroups.size(); i++) {
       InflectionalGroup ig = inflectionalGroups.get(i);
       SuffixData suffixData = ig.suffixList.get(0);
       if (suffixData.surface.length() > 0) {
         String surface = suffixData.surface;
         if (suffixData.lex.endsWith("~k")) {
           surface = surface.substring(0, surface.length() - 1) + "k";
         }
         String stem = previousStem + surface;
         if (!lemmas.contains(stem)) lemmas.add(stem);
       }
       previousStem = previousStem + ig.surfaceForm();
     }
   }
   return lemmas;
 }
Ejemplo n.º 6
0
 public boolean containsSuffix(Suffix suffix) {
   for (InflectionalGroup inflectionalGroup : inflectionalGroups) {
     if (inflectionalGroup.containsSuffix(suffix)) return true;
   }
   return false;
 }