Examples of SnowballProgram


Examples of org.tartarus.snowball.SnowballProgram

    this.logger.log(Level.INFO, "Snowball annotator starts processing");

    // get get stemmer for the document language
    String language = new Language(aJCas.getDocumentLanguage()).getLanguagePart();

    SnowballProgram stemmer = this.stemmers.get(language);

    // create stemms if stemmer for the current document language is available
    if (stemmer != null) {

      // get stem() method from stemmer
      Method stemmerStemMethod;
      try {
        stemmerStemMethod = stemmer.getClass().getMethod("stem", new Class[0]);
      } catch (Exception ex) {
        throw new AnalysisEngineProcessException(ex);
      }

      // iterate over all token annotations and add stem if available
      FSIterator<Annotation> tokenIterator = aJCas.getAnnotationIndex(TokenAnnotation.type).iterator();
      while (tokenIterator.hasNext()) {
        // get token content
        TokenAnnotation annot = (TokenAnnotation) tokenIterator.next();
        String span = annot.getCoveredText();

        // set annotation content and call stemmer
        try {
          stemmer.setCurrent(span);
          stemmerStemMethod.invoke(stemmer, emptyArgs);
        } catch (Exception ex) {
          throw new AnalysisEngineProcessException(ex);
        }

        // get stemmer result and set annotation feature
        annot.setStem(stemmer.getCurrent());
      }
    } else {
      if (language.equals("x")) {
        this.logger.log(Level.WARNING, "Language of the CAS is set to 'x', SnowballAnnotator skipped processing.");
      }
View Full Code Here

Examples of org.tartarus.snowball.SnowballProgram

      throw new RuntimeException("Can't find class for stemmer language " + language, e);
    }
  }
 
  public TokenFilter create(TokenStream input) {
    SnowballProgram program;
    try {
      program = (SnowballProgram)stemClass.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("Error instantiating stemmer for language " + language + "from class " +stemClass, e);
    }
View Full Code Here

Examples of org.tartarus.snowball.SnowballProgram

      throw new RuntimeException("Can't find class for stemmer language " + language, e);
    }
  }
 
  public SnowballFilter create(TokenStream input) {
    SnowballProgram program;
    try {
      program = (SnowballProgram)stemClass.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("Error instantiating stemmer for language " + language + "from class " +stemClass, e);
    }
View Full Code Here

Examples of org.tartarus.snowball.SnowballProgram

      throw new RuntimeException("Can't find class for stemmer language " + language, e);
    }
  }
 
  public SnowballPorterFilter create(TokenStream input) {
    SnowballProgram program;
    try {
      program = (SnowballProgram)stemClass.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("Error instantiating stemmer for language " + language + "from class " +stemClass, e);
    }
View Full Code Here

Examples of org.tartarus.snowball.SnowballProgram

    }
  }

  @Override
  public TokenFilter create(TokenStream input) {
    SnowballProgram program;
    try {
      program = stemClass.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("Error instantiating stemmer for language " + language + "from class " + stemClass, e);
    }
View Full Code Here

Examples of org.tartarus.snowball.SnowballProgram

      throw new RuntimeException( "Can't find class for stemmer language " + language, e );
    }
  }

  public SnowballPorterFilter create(TokenStream input) {
    SnowballProgram program;
    try {
      program = ( SnowballProgram ) stemClass.newInstance();
    }
    catch ( Exception e ) {
      throw new RuntimeException(
View Full Code Here

Examples of org.tartarus.snowball.SnowballProgram

    }
  }

  @Override
  public TokenFilter create(TokenStream input) {
    SnowballProgram program;
    try {
      program = stemClass.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("Error instantiating stemmer for language " + language + "from class " + stemClass, e);
    }
View Full Code Here

Examples of org.tartarus.snowball.SnowballProgram

    this.logger.log(Level.INFO, "Snowball annotator starts processing");

    // get get stemmer for the document language
    String language = new Language(aJCas.getDocumentLanguage()).getLanguagePart();
    SnowballProgram stemmer = (SnowballProgram) this.stemmers.get(language);

    // create stemms if stemmer for the current document language is available
    if (stemmer != null) {

      // get stem() method from stemmer
      Method stemmerStemMethod;
      try {
        stemmerStemMethod = stemmer.getClass().getMethod("stem", new Class[0]);
      } catch (Exception ex) {
        throw new AnnotatorProcessException(ex);
      }

      // iterate over all token annotations and add stem if available
      FSIterator tokenIterator = aJCas.getCas().getAnnotationIndex(this.tokenAnnotation).iterator();
      while (tokenIterator.hasNext()) {
        // get token content
        AnnotationFS annot = (AnnotationFS) tokenIterator.next();
        String span = annot.getCoveredText();

        // set annotation content and call stemmer
        try {
          stemmer.setCurrent(span);
          stemmerStemMethod.invoke(stemmer, emptyArgs);
        } catch (Exception ex) {
          throw new AnnotatorProcessException(ex);
        }

        // get stemmer result and set annotation feature
        annot.setStringValue(this.tokenAnnotationStemmFeature, stemmer.getCurrent());
      }
    }
    this.logger.log(Level.INFO, "Snowball annotator processing finished");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.