// Path: src/hu/u_szeged/nlp/pos/HungarianMorphology.java
// public class HungarianMorphology {
// 
//   public static String[] getPossibleTags(String word, Set<String> possibleTags) {
//     Set<MorAna> morAnas = null;
//     Set<String> res = null;
//     String reduced = null;
// 
//     morAnas = HunLemMor.getMorphologicalAnalyses(word);
//     res = new HashSet<String>();
// 
//     for (MorAna morAna : morAnas) {
//       reduced = MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd());
//       if (possibleTags.contains(reduced)) {
//         res.add(reduced);
//       }
//     }
// 
//     if (res.size() == 0) {
//       res.add("X");
//     }
// 
//     return res.toArray(new String[res.size()]);
//   }
// 
//   public static List<CoreLabel> recoverTags(List<CoreLabel> sentence) {
//     Set<MorAna> set = null;
//     for (CoreLabel tw : sentence) {
//       set = HunLemMor.getMorphologicalAnalyses(tw.word());
//       int max = -1;
//       MorAna argmax = null;
// 
//       for (MorAna morAna : set) {
// 
//         int freq = MagyarlancResourceHolder.getFrequencies().containsKey(morAna.getMsd()) ? MagyarlancResourceHolder.getFrequencies().get(morAna.getMsd()) : 0;
// 
//         if (!morAna.getMsd().equals(null)) {
//           if (MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd()).equals(tw.tag()) && (max < freq)) {
//             argmax = morAna;
//             max = freq;
//           }
//         }
//       }
// 
//       if (argmax != null) {
//         tw.setLemma(argmax.getLemma());
//         tw.setTag(argmax.getMsd());
//       } else {
//         tw.setLemma(tw.word());
//       }
//     }
//     return sentence;
//   }
// }


import hu.u_szeged.nlp.pos.HungarianMorphology;
import java.util.List;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.Timing;
package edu.stanford.nlp.pipeline;




public class OwnMorphaAnnotator extends MorphaAnnotator {

  private Timing timer = new Timing();
  private boolean VERBOSE = false;
  private boolean isEnglish;

  public OwnMorphaAnnotator(boolean english) {
    this(false, english);
  }

  public OwnMorphaAnnotator(boolean verbose, boolean english) {
    super(verbose);
    VERBOSE = verbose;
    isEnglish = english;
  }

  public void annotate(Annotation annotation) {
    if (VERBOSE) {
      timer.start();
      System.err.print("Finding lemma...");
    }
    if (isEnglish) {
      super.annotate(annotation);
    } else {
      if (annotation.has(CoreAnnotations.SentencesAnnotation.class)) {
        List<CoreMap> sentences = annotation.get(SentencesAnnotation.class);
        for (CoreMap sentence : sentences) {
          List<CoreLabel> tokens = sentence.get(TokensAnnotation.class);
// Path: src/hu/u_szeged/nlp/pos/HungarianMorphology.java
// public class HungarianMorphology {
// 
//   public static String[] getPossibleTags(String word, Set<String> possibleTags) {
//     Set<MorAna> morAnas = null;
//     Set<String> res = null;
//     String reduced = null;
// 
//     morAnas = HunLemMor.getMorphologicalAnalyses(word);
//     res = new HashSet<String>();
// 
//     for (MorAna morAna : morAnas) {
//       reduced = MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd());
//       if (possibleTags.contains(reduced)) {
//         res.add(reduced);
//       }
//     }
// 
//     if (res.size() == 0) {
//       res.add("X");
//     }
// 
//     return res.toArray(new String[res.size()]);
//   }
// 
//   public static List<CoreLabel> recoverTags(List<CoreLabel> sentence) {
//     Set<MorAna> set = null;
//     for (CoreLabel tw : sentence) {
//       set = HunLemMor.getMorphologicalAnalyses(tw.word());
//       int max = -1;
//       MorAna argmax = null;
// 
//       for (MorAna morAna : set) {
// 
//         int freq = MagyarlancResourceHolder.getFrequencies().containsKey(morAna.getMsd()) ? MagyarlancResourceHolder.getFrequencies().get(morAna.getMsd()) : 0;
// 
//         if (!morAna.getMsd().equals(null)) {
//           if (MagyarlancResourceHolder.getMSDReducer().reduce(morAna.getMsd()).equals(tw.tag()) && (max < freq)) {
//             argmax = morAna;
//             max = freq;
//           }
//         }
//       }
// 
//       if (argmax != null) {
//         tw.setLemma(argmax.getLemma());
//         tw.setTag(argmax.getMsd());
//       } else {
//         tw.setLemma(tw.word());
//       }
//     }
//     return sentence;
//   }
// }


// Path: src/edu/stanford/nlp/pipeline/OwnMorphaAnnotator.java
import hu.u_szeged.nlp.pos.HungarianMorphology;
import java.util.List;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation;
import edu.stanford.nlp.ling.CoreAnnotations.TokensAnnotation;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.util.CoreMap;
import edu.stanford.nlp.util.Timing;

package edu.stanford.nlp.pipeline;




public class OwnMorphaAnnotator extends MorphaAnnotator {

  private Timing timer = new Timing();
  private boolean VERBOSE = false;
  private boolean isEnglish;

  public OwnMorphaAnnotator(boolean english) {
    this(false, english);
  }

  public OwnMorphaAnnotator(boolean verbose, boolean english) {
    super(verbose);
    VERBOSE = verbose;
    isEnglish = english;
  }

  public void annotate(Annotation annotation) {
    if (VERBOSE) {
      timer.start();
      System.err.print("Finding lemma...");
    }
    if (isEnglish) {
      super.annotate(annotation);
    } else {
      if (annotation.has(CoreAnnotations.SentencesAnnotation.class)) {
        List<CoreMap> sentences = annotation.get(SentencesAnnotation.class);
        for (CoreMap sentence : sentences) {
          List<CoreLabel> tokens = sentence.get(TokensAnnotation.class);
          HungarianMorphology.recoverTags(tokens);