コード例 #1
0
ファイル: MorphParse.java プロジェクト: sumnulu/zemberek-nlp
 /**
  * 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;
 }
コード例 #2
0
ファイル: MorphParse.java プロジェクト: sumnulu/zemberek-nlp
 /**
  * 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;
 }