I'm working on a project of Word Sense Disambiguation and I want to find all the occurrences in a file of a given root e.g. the root is "love" the programme will give us all the words in the file that is derived from "love" like lovely, loved... I did some work but I didn't get what I want!
`
package partenn1;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Partenn1 {
public static void main(String[] args) {
int c=0;
String w = "tissue";
try (BufferedReader br = new BufferedReader(new FileReader("D:/Sc46.txt")))
{
String line;
while ((line = br.readLine()) != null)
{
String[] WrdsLine = line.split(" ");
boolean findwrd = false;
for( String WrdLine : WrdsLine )
{
for (int a=0; a<WrdsLine.length; a++)
{
if ( WrdsLine[a].indexOf(w)!=0)
{
c++; //It's just a counter for verification of the numbre of the occ.
findwrd = true;
}
}
}
}
System.out.println(c);
}
catch (IOException e) {}
}
}
`
Aucun commentaire:
Enregistrer un commentaire