-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstemming.java
More file actions
52 lines (42 loc) · 1.01 KB
/
stemming.java
File metadata and controls
52 lines (42 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Venkata Harish Kajur 8982
* Jonathan Lysiak 4477
* CS-345
* Homework 6
*/
import java.io.*;
import java.util.*;
/*
* Stems files to associate them to their root word in the lexicon
*/
public class stemming {
public static String stem(String word){
if(word.endsWith("ies")){
if(!word.endsWith("eies") && !word.endsWith("aies")){
word = word.substring(0,word.length() - 3) + "y";
return word;
}
}
if(word.endsWith("es")){
if(!word.endsWith("aes") && !word.endsWith("ees") && !word.endsWith("oes")){
word = word.substring(0,word.length() - 2) + "s";
return word;
}
}
if(word.endsWith("s")){
if(!word.endsWith("us") && !word.endsWith("ss")){
word = word.substring(0,word.length() - 1) + "";
return word;
}
}
return word;
}
public static void main(String[] args){
try {
String line = args[0];
System.out.println(stem(line));
} catch(Exception ex){
ex.printStackTrace();
}
}
}