Beispiel #1
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;
  }