1 package gate.creole.morph;
2
3
11
12 public class MorphFunctions {
13
14
15 private String input;
16
17 private String affix;
18
19 private int len;
20
21
24 public MorphFunctions() {
25
26 }
27
28
33 public String getAffix() {
34 if(affix==null) {
35 return " ";
36 } else {
37 return affix;
38 }
39 }
40
41
45 public void setInput(String input) {
46 this.input = input;
47 this.len = input.length();
48 this.affix = null;
49 }
50
51
57 public String stem(int del, String add, String affix) {
58 int stem_length = len - del;
59 String result = this.input.substring(0,stem_length)+add;
60 this.affix = affix;
61 return result;
62 }
64
65
70 public String semi_reg_stem(int del, String add) {
71 int stem_length = len - del;
72 int inputLength = len;
73
74
75 if(input.charAt(inputLength-1) == 's' || input.charAt(inputLength-1) == 'S') {
76 stem_length-=1;
77 this.affix = "s";
78 }
79
80
81 if(input.charAt(inputLength-1) == 'd' || input.charAt(inputLength-1) == 'D') {
82 stem_length-=2;
83 this.affix = "ed";
84 }
85
86
87 if(input.charAt(inputLength-1) == 'g' || input.charAt(inputLength-1) == 'G') {
88 stem_length-=3;
89 this.affix = "ing";
90 }
91
92 String result = input.substring(0,stem_length)+add;
93 return result;
94 }
96
97
100 public String irreg_stem(String root, String affix) {
101 String result = root;
102 this.affix = affix;
103 return result;
104 }
106
107
110 public String null_stem() {
111 String result = input;
112 return result;
113 } }