package iitb.cfilt.cpost.ngi;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;

import iitb.cfilt.cpost.ConfigReader;
import iitb.cfilt.cpost.dmstemmer.MAResult;
import iitb.cfilt.cpost.dmstemmer.NewStemmer;

public class NgiResult 
{
	private Vector<String> postags;
	private String Token;
	private String assignedTag;
	private String finalTag;
	private int set;
	private boolean changed;
	public NgiResult()
	{
		postags = new Vector<String>();
		Token = new String();
		assignedTag = new String();
		finalTag = new String();
		set = 5;
		changed = false;
	}
	public NgiResult(MAResult maresult)
	{
		postags = new Vector<String>();
		Token = new String();
		assignedTag = new String();
		finalTag = new String();
		set = 5;
		changed = false;
		setpostags(maresult);
		setToken(maresult.getToken());
	}
	public NgiResult(String Token)
	{
		postags = new Vector<String>();
		Token = new String();
		assignedTag = new String();
		finalTag = new String();
		set = 5;
		changed = false;
		setpostags(Token);
		setToken(Token);
	}
	public NgiResult(MAResult maresult, String assignedTag)
	{
		postags = new Vector<String>();
		Token = new String();
		this.assignedTag = new String();
		finalTag = new String();
		set = 5;
		changed = false;
		setpostags(maresult);
		setToken(maresult.getToken());
		setassignedTag(assignedTag);
		setset();
	}
	public Vector<String> getpostags()
	{
		return postags;
	}
	public String getToken()
	{
		return Token;
	}
	public String getassignedTag()
	{
		return assignedTag;
	}
	public String getfinaltag()
	{
		return finalTag;
	}
	public int getset()
	{
		return set;
	}
	public boolean getchanged()
	{
		return changed;
	}
	public void setpostags(MAResult maresult)
	{
		for(int i=0;i<maresult.getMorphOutputs().size();i++)
		{
			if((maresult.getMorphOutputs().get(i).getStemmerResult().getCategory()!=null) && !(maresult.getMorphOutputs().get(i).getStemmerResult().getCategory().toString().trim().equals("")))
				postags.add(maresult.getMorphOutputs().get(i).getStemmerResult().getCategory());
		}
	}
	public void setpostags(String Token)
	{
		NewStemmer dmstemmer = new NewStemmer();
		MAResult maresult= dmstemmer.stem(Token);
		for(int i=0;i<maresult.getMorphOutputs().size();i++)
		{
			if(maresult.getMorphOutputs().get(i).getStemmerResult().getCategory()!=null)
				postags.add(maresult.getMorphOutputs().get(i).getStemmerResult().getCategory());
		}
	}
	public void setpostags(Vector<String> postags)
	{
		this.postags = postags;
	}
	public void setToken(String Token)
	{
		this.Token = Token;
	}
	public void setassignedTag(String assignedTag)
	{
		this.assignedTag = assignedTag;
	}
	public void setfinalTag(String finalTag)
	{
		this.finalTag = finalTag;
	}
	public void setset()
	{
		if(!assignedTag.isEmpty())
		{
			if((assignedTag.equals("DEM")) || (assignedTag.equals("INTF")) || (assignedTag.equals("QF")) || (assignedTag.equals("QO")) || (assignedTag.equals("QC")))
				set = 1;
			else if(assignedTag.equals("JJ"))
				set = 2;
			else if((assignedTag.equals("NN")) || (assignedTag.equals("NNP")) || (assignedTag.equals("PRP")))
				set = 3;
			else if(assignedTag.equals("PSP"))
				set = 4;
			else
				set = 5;
		}
		else
			set = 5;
	}
	public void setchanged(boolean changed)
	{
		this.changed = changed;
	}
	public void printresults()
	{
		System.out.println("Token : " + Token + "\tOld Tag : " + assignedTag + "\tNew Tag : " + finalTag + "\tchanged : " + changed + "\tSet : " + set);
	}
	public static void main(String[] args)
	{
		ConfigReader.read(args[0]);
		NewStemmer dmstemmer = new NewStemmer();
		String sentence = "राम खाना खाता है .";
		String tokens[] = sentence.split(" ");
		List<String> lis = Arrays.asList(tokens);
		List<String> list = lis;
		Vector<String> tokenList = new Vector<String>(list);
		Vector<MAResult> mrv = new Vector<MAResult>();	
		for(int temp=0;temp<tokenList.size();temp++)
		{
			if(tokenList.get(temp)==null)
				continue;
			MAResult Mar = dmstemmer.stem(tokenList.get(temp));
			mrv.add(Mar);
		}
		Vector<String> assignedtags = new Vector<String>();
		assignedtags.add("NN");
		assignedtags.add("NN");
		assignedtags.add("VM");
		assignedtags.add("VAUX");
		assignedtags.add("SYM");
		Vector<NgiResult> ngioutput = new Vector<NgiResult>();
		for(int i=0;i<mrv.size();i++)
			ngioutput.add(new NgiResult(mrv.get(i),assignedtags.get(i)));
		for (int i=0;i<ngioutput.size();i++)
			ngioutput.get(i).printresults();
	}
}
