package iitb.cfilt.cpost.dmstemmer;

import java.util.*;

public class MAResult {
	String token;
	Vector<MorphOutput2> morphOutputs;
	
	public Vector<MorphOutput2> getMorphOutputs() {
		return morphOutputs;
	}
	public void setMorphOutputs(Vector<MorphOutput2> morphOutputs) {
		this.morphOutputs = morphOutputs;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
		//this.morphOutputs = new Vector<MorphOutput2>();
	}
	public MAResult(String token, Vector<MorphOutput2> morphOutputs) {		
		this.token = token;
		this.morphOutputs = morphOutputs;
	}
	public MAResult(String token) {		
		this.token = token;
	}
	public void addMorphOutput(MorphOutput2 mo){
		this.morphOutputs.add(mo);
	}
	public void addMorphOutputs(Vector<MorphOutput2> mos){
		this.morphOutputs.addAll(mos);
	}
	public void print(){
		System.out.println("Token : " + this.token + ",  Total Output : " + morphOutputs.size());
		for(int mos=0; mos<morphOutputs.size(); mos++){
			morphOutputs.get(mos).print();
		}
	}
	public void printDetail(){
		System.out.println("Token : " + this.token + ",  Total Output : " + morphOutputs.size());
		for(int mos=0; mos<morphOutputs.size(); mos++){
			morphOutputs.get(mos).printDetail();
		}
	}
	
	public String getAmbiguityScheme(){
		String retVal = "";
				
		HashSet<String> categorySet = new HashSet<String>();
		for(MorphOutput2 mrot : morphOutputs){
			String cat = mrot.getStemmerResult().getCategory().trim();
			if(!cat.equals("unknown")){
				categorySet.add(cat);
			}
		}
		Vector<String> categoryList = new Vector<String>(categorySet);
		Collections.sort(categoryList);
		for(int i = 0; i < categoryList.size(); i++){
			retVal += categoryList.get(i) + "*";
		}
		if(!retVal.equals(""))
			retVal = retVal.substring(0, retVal.length() - 1);
		return retVal;
	}
}
