* @throws Exception
*/
public static void readLemma(DataBroker dic,String lemma,Element word,String pos)throws Exception
{
String lem=lemma+"_"+pos;
Lemma l=null;
ArrayList<Sense> senses=dic.getSenses(lem);
BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
if(senses.size()==0)//
{
if(!SemCorCleaner.fix)
{
System.out.println("Lemma not found: "+lem);
System.out.println("Please enter a lemma or no for ignoring this word!");
String plemma=kb.readLine();
if(plemma.equals("no"))
{
word.setAttribute("cmd","ignore");
}
else
{
l=dic.getLemma(plemma);
while(l==null)
{
System.out.println("Please write the valid form (lemma_P where lemma is in normal form and P is the first letter of the pos tag)");
plemma=kb.readLine();
l=dic.getLemma(plemma);
}
word.setAttribute("lemma",l.getLemma().substring(0,l.getLemma().length()-2));
word.setAttribute("pos",l.getPos());
word.setAttribute("wnsn","-1");
}
}
else
{
System.out.println("Marking "+word.getValue()+" for future tagging ");
word.setAttribute("cmd","tag");
}
}
else
{
System.out.println("\n<"+word.getValue()+"> may not be in normal form");
ArrayList<String> morphs=dic.Morphy(lemma, pos);
do
{
String plemma;
if(morphs.size()==1)
{
plemma=morphs.get(0)+"_"+pos;
System.out.println(lemma+" was autocorrected to "+ plemma);
}
else
{
if(!SemCorCleaner.fix)
{
System.out.println("Please select the valid form (lemma_P where lemma is in normal form and P is the first letter of the pos tag).\nSome suggestions are "+morphs+" just remember to add the _"+pos+" pos tagat the end of the lemma");
plemma=kb.readLine();
}
else
{
System.out.println("Marking "+word.getValue()+" for future tagging ");
word.setAttribute("cmd","tag");
break;
}
}
l=dic.getLemma(plemma);
}
while(l==null&&!SemCorCleaner.fix);
if(l!=null)
{
word.setAttribute("lemma",l.getLemma().substring(0,l.getLemma().length()-2));
word.setAttribute("pos",l.getPos());
word.setAttribute("wnsn","-1");
}
}
}