{
String readPOS;
readPOS = jTextArea1.getText();
String []POS;
POS = readPOS.split("[-.!? ]");
jTextArea2.append("Part of Speech Result:\n");
String patternKGN,patternKPF,patternKK,patternKNA,patternKPA,
patternKPC,patternKPK,patternKS;
for(int i = 0; i < POS.length; i++)
{
try {
File readKGN = new File("KGNLibrary.txt");
FileReader outKGN = new FileReader(readKGN);
char[] buf = new char[(int)readKGN.length()];
outKGN.read(buf);
patternKGN = new String(buf);
StringTokenizer KGNLib = new StringTokenizer(patternKGN);
while (KGNLib.hasMoreElements())
if (POS[i].equals(KGNLib.nextToken()))
{
jTextArea2.append(POS[i] + "/KGN" + " | ");
}
File readKPF = new File("KPFLibrary.txt");
FileReader outKPF = new FileReader(readKPF);
char[] buf1 = new char[(int)readKPF.length()];
outKPF.read(buf1);
patternKPF = new String(buf1);
StringTokenizer KPFLib = new StringTokenizer(patternKPF);
while (KPFLib.hasMoreElements())
if (POS[i].equals(KPFLib.nextToken()))
{
jTextArea2.append(POS[i] + "/KPF" + " | ");
}
File readKK = new File("KKLibrary.txt");
FileReader outKK = new FileReader(readKK);
char[] buf2 = new char[(int)readKK.length()];
outKK.read(buf2);
patternKK = new String(buf2);
StringTokenizer KKLib = new StringTokenizer(patternKK);
while (KKLib.hasMoreElements())
if (POS[i].equals(KKLib.nextToken()))
{
jTextArea2.append(POS[i] + "/KK" + " | ");
}
File readKNA = new File("KNALibrary.txt");
FileReader outKNA = new FileReader(readKNA);
char[] buf3 = new char[(int)readKNA.length()];
outKNA.read(buf3);
patternKNA = new String(buf3);
StringTokenizer KNALib = new StringTokenizer(patternKNA);
while (KNALib.hasMoreElements())
if (POS[i].equals(KNALib.nextToken()))
{
jTextArea2.append(POS[i] + "/KNA" + " | ");
}
File readKPA = new File("KPALibrary.txt");
FileReader outKPA = new FileReader(readKPA);
char[] buf4 = new char[(int)readKPA.length()];
outKPA.read(buf4);
patternKPA = new String(buf4);
StringTokenizer KPALib = new StringTokenizer(patternKPA);
while (KPALib.hasMoreElements())
if (POS[i].equals(KPALib.nextToken()))
{
jTextArea2.append(POS[i] + "/KPA" + " | ");
}
File readKPC = new File("KPCLibrary.txt");
FileReader outKPC = new FileReader(readKPC);
char[] buf5 = new char[(int)readKPC.length()];
outKPC.read(buf5);
patternKPC = new String(buf5);
StringTokenizer KPCLib = new StringTokenizer(patternKPC);
while (KPCLib.hasMoreElements())
if (POS[i].equals(KPCLib.nextToken()))
{
jTextArea2.append(POS[i] + "/KPC" + " | ");
}
File readKPK = new File("KPKLibrary.txt");
FileReader outKPK = new FileReader(readKPK);
char[] buf6 = new char[(int)readKPK.length()];
outKPK.read(buf6);
patternKPK = new String(buf6);
StringTokenizer KPKLib = new StringTokenizer(patternKPK);
while (KPKLib.hasMoreElements())
if (POS[i].equals(KPKLib.nextToken()))
{
jTextArea2.append(POS[i] + "/KPK" + " | ");
}
File readKS = new File("KSLibrary.txt");
FileReader outKS = new FileReader(readKS);
char[] buf7 = new char[(int)readKS.length()];
outKS.read(buf7);
patternKS = new String(buf7);
StringTokenizer KSLib = new StringTokenizer(patternKS);
while (KSLib.hasMoreElements())
if (POS[i].equals(KSLib.nextToken()))
{
jTextArea2.append(POS[i] + "/KS" + " | ");
}
File readKNK = new File("KNKLibrary.txt");
FileReader outKNK = new FileReader(readKNK);
char[] buf8 = new char[(int)readKNK.length()];
outKNK.read(buf8);
patternKS = new String(buf8);
StringTokenizer KNKLib = new StringTokenizer(patternKS);
while (KNKLib.hasMoreElements())
if (POS[i].equals(KNKLib.nextToken()))
{
jTextArea2.append(POS[i] + "/KNK" + " | ");
}
else if ((!POS[i].equals(KNKLib.nextToken())||(!POS[i].equals(KSLib.nextToken())))
||(!POS[i].equals(KPKLib.nextToken()))||(!POS[i].equals(KPCLib.nextToken()))
||(!POS[i].equals(KPALib.nextToken()))||(!POS[i].equals(KNALib.nextToken()))
||(!POS[i].equals(KKLib.nextToken()))||(!POS[i].equals(KPFLib.nextToken()))
||(!POS[i].equals(KGNLib.nextToken())))
{
jTextArea2.append(POS[i] + "/KNK" + " | ");
}
}catch (IOException ex) {
Logger.getLogger(PartOfSpeechView.class.getName()).log(Level.SEVERE, null, ex);}
}
i wan my output if not same with all data in all text file then will be did jTextArea2.append(POS + "/KNK" + " | "); , my problem is once detect data in text file then will print 2 times.
like "Saya" in data of KPALib.txt" then output will become "Saya/KPA Saya/KNK". i wan it only "Saya/KPA" and dun wan "Saya/KNK". Can anyone help me fix tis?