
gate.creole.morph.MorphFunctions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tools Show documentation
Show all versions of tools Show documentation
A selection of processing resources commonly used to extend ANNIE
The newest version!
package gate.creole.morph;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2003
* Company:
* @author not attributable
* @version 1.0
*/
public class MorphFunctions {
/** The word for which the program should find the root and the affix */
private String input;
/** Affix to the root word */
private String affix;
/** Length of the word provided to the program */
private int len;
/**
* Default Constructor
*/
public MorphFunctions() {
}
/**
* Method returns the found affix of the word provided to the program, for
* which the root and the affix has to be found
* @return affix if found, " " otherwise
*/
public String getAffix() {
if(affix==null) {
return " ";
} else {
return affix;
}
}
/**
* Sets the input for which the roor entry has to be found in the program
* @param input
*/
public void setInput(String input) {
this.input = input;
this.len = input.length();
this.affix = null;
}
/**
* Deletes the "del" given number of characters from right,
*
appends the "add" given string at the end and
*
sets the affix as "affix"
*
and returns this new string
*/
public String stem(int del, String add, String affix) {
int stem_length = len - del;
String result = this.input.substring(0,stem_length)+add;
this.affix = affix;
return result;
} // method stem()
/**
* Deletes the "del" given number of characters from right,
*
appends the "add" given string at the end
*
and returns this new string
*/
public String semi_reg_stem(int del, String add) {
int stem_length = len - del;
int inputLength = len;
/* look for -es, -ed, -ing; cannot be anything else */
if(input.charAt(inputLength-1) == 's' || input.charAt(inputLength-1) == 'S') {
stem_length-=2;
this.affix = "s";
}
if(input.charAt(inputLength-1) == 'd' || input.charAt(inputLength-1) == 'D') {
stem_length-=2;
this.affix = "ed";
}
if(input.charAt(inputLength-1) == 'g' || input.charAt(inputLength-1) == 'G') {
stem_length-=3;
this.affix = "ing";
}
String result = input.substring(0,stem_length)+add;
return result;
} // method semi_reg_stem()
/**
* returns the "root" as result and sets "affix" as affix
*/
public String irreg_stem(String root, String affix) {
String result = root;
this.affix = affix;
return result;
} // method irreg_stem()
/**
* returns the input as the root word
*/
public String null_stem() {
String result = input;
return result;
} // method null_stem()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy