package data;

import gui.I18N;

public enum CalculateFor {
	WORD("calculateFor.WORD"),
	LOWERCASE_WORD("calculateFor.LOWERCASE_WORD"),
	NORMALIZED_WORD("calculateFor.NORMALIZED_WORD"),
	LEMMA("calculateFor.LEMMA"),
	MORPHOSYNTACTIC_SPECS("calculateFor.MORPHOSYNTACTIC_SPECS"),
	MORPHOSYNTACTIC_PROPERTY("calculateFor.MORPHOSYNTACTIC_PROPERTY"),
	WORD_TYPE("calculateFor.WORD_TYPE"),
	DIST_WORDS("calculateFor.DIST_WORDS"),
	DIST_LEMMAS("calculateFor.DIST_LEMMAS");


	private final String name;

	CalculateFor(String name) {
		this.name = name;
	}

	public String toString() {
		return I18N.get(this.name);
	}

	public static CalculateFor factory(String cf) {
		if (cf != null) {
			if (WORD.toString().equals(cf)) {
				return WORD;
			}
			if (LOWERCASE_WORD.toString().equals(cf)) {
				return LOWERCASE_WORD;
			}
			if (LEMMA.toString().equals(cf)) {
				return LEMMA;
			}
			if (MORPHOSYNTACTIC_SPECS.toString().equals(cf)) {
				return MORPHOSYNTACTIC_SPECS;
			}
			if (MORPHOSYNTACTIC_PROPERTY.toString().equals(cf)) {
				return MORPHOSYNTACTIC_PROPERTY;
			}
			if (WORD_TYPE.toString().equals(cf)) {
				return WORD_TYPE;
			}
			if (NORMALIZED_WORD.toString().equals(cf)) {
				return NORMALIZED_WORD;
			}
		}
		return null;
	}

	public String totalSumString(int ngram) {
		if (ngram == 0) {
			switch (this) {
				case WORD:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.word");
				case LOWERCASE_WORD:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.lowercaseWord");
				case NORMALIZED_WORD:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.normalizedWord");
				case LEMMA:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.lemma");
				case MORPHOSYNTACTIC_SPECS:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.msd");
				case MORPHOSYNTACTIC_PROPERTY:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.msdProperty");
				case WORD_TYPE:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.wordType");
				case DIST_WORDS:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.word");
				case DIST_LEMMAS:
					return I18N.get("exportTable.part.totalSumLetters") + " " + I18N.get("exportTable.part.lemma");
				default:
					return null;
			}
		} else if (ngram >= 1) {
			switch (this) {
				case WORD:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.word");
				case LOWERCASE_WORD:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.lowercaseWord");
				case NORMALIZED_WORD:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.normalizedWord");
				case LEMMA:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.lemma");
				case MORPHOSYNTACTIC_SPECS:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.msd");
				case MORPHOSYNTACTIC_PROPERTY:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.msdProperty");
				case WORD_TYPE:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.wordType");
				case DIST_WORDS:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.word");
				case DIST_LEMMAS:
					return I18N.get("exportTable.part.totalSumString") + " " + I18N.get("exportTable.part.lemma");
				default:
					return null;
			}
		}
		return null;
	}

	public String foundSumString(int ngram) {
		if (ngram == 0) {
			switch (this) {
				case WORD:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.word");
				case LOWERCASE_WORD:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.lowercaseWord");
				case NORMALIZED_WORD:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.normalizedWord");
				case LEMMA:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.lemma");
				case MORPHOSYNTACTIC_SPECS:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.msd");
				case MORPHOSYNTACTIC_PROPERTY:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.msdProperty");
				case WORD_TYPE:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.wordType");
				case DIST_WORDS:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.word");
				case DIST_LEMMAS:
					return I18N.get("exportTable.part.totalFoundLetters") + " " + I18N.get("exportTable.part.lemma");
				default:
					return null;
			}
		} else if (ngram >= 1) {
			switch (this) {
				case WORD:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.word");
				case LOWERCASE_WORD:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.lowercaseWord");
				case NORMALIZED_WORD:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.normalizedWord");
				case LEMMA:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.lemma");
				case MORPHOSYNTACTIC_SPECS:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.msd");
				case MORPHOSYNTACTIC_PROPERTY:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.msdProperty");
				case WORD_TYPE:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.wordType");
				case DIST_WORDS:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.word");
				case DIST_LEMMAS:
					return I18N.get("exportTable.part.totalFound") + " " + I18N.get("exportTable.part.lemma");
				default:
					return null;
			}
		}

		return null;
	}

	public String totalAbsoluteFrequencyString(int ngram) {
		if (ngram == 0) {
			return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.letterSet");
		}
		switch(this){
			case WORD:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.word2");
			case LOWERCASE_WORD:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.lowercaseWord2");
			case NORMALIZED_WORD:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.normalizedWord2");
			case LEMMA:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.lemma2");
			case MORPHOSYNTACTIC_SPECS:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.msd2");
			case MORPHOSYNTACTIC_PROPERTY:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.msdProperty2");
			case WORD_TYPE:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.wordType2");
			case DIST_WORDS:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.word2");
			case DIST_LEMMAS:
				return I18N.get("exportTable.part.absoluteFrequency") + " " + I18N.get("exportTable.part.lemma2");
			default:
				return null;
		}
	}

	public String shareOfTotalString(int ngram) {
		if (ngram == 0) {
			return I18N.get("exportTable.part.letterSet2");
		}
		switch(this){
			case WORD:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.word2");
			case LOWERCASE_WORD:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.lowercaseWord2");
			case NORMALIZED_WORD:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.normalizedWord2");
			case LEMMA:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.lemma2");
			case MORPHOSYNTACTIC_SPECS:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.msd2");
			case MORPHOSYNTACTIC_PROPERTY:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.msdProperty2");
			case WORD_TYPE:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.wordType2");
			case DIST_WORDS:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.word2");
			case DIST_LEMMAS:
				return I18N.get("exportTable.part.share") + " " + I18N.get("exportTable.part.lemma2");
			default:
				return null;
		}
	}

	public String toHeaderString(int ngram) {
		if (ngram == 0) {
			return I18N.get("exportTable.part.letterSet3");
		} else if (ngram == 1) {
			switch (this) {
				case WORD:
				case DIST_WORDS:
					return I18N.get("exportTable.part.word3");
				case LOWERCASE_WORD:
					return I18N.get("exportTable.part.lowercaseWord3");
				case NORMALIZED_WORD:
					return I18N.get("exportTable.part.normalizedWord3");
				case LEMMA:
				case DIST_LEMMAS:
					return I18N.get("exportTable.part.lemma3");
				case MORPHOSYNTACTIC_SPECS:
					return I18N.get("exportTable.part.msd3");
				case MORPHOSYNTACTIC_PROPERTY:
					return I18N.get("exportTable.part.msdProperty3");
				case WORD_TYPE:
					return I18N.get("exportTable.part.wordType3");
				default:
					return null;
			}
		}
		switch (this) {
			case WORD:
			case DIST_WORDS:
				return I18N.get("exportTable.part.word3") + " " + I18N.get("exportTable.part.set");
			case LOWERCASE_WORD:
				return I18N.get("exportTable.part.lowercaseWord3") + " " + I18N.get("exportTable.part.set");
			case NORMALIZED_WORD:
				return I18N.get("exportTable.part.normalizedWord3") + " " + I18N.get("exportTable.part.set");
			case LEMMA:
			case DIST_LEMMAS:
				return I18N.get("exportTable.part.lemma3") + " " + I18N.get("exportTable.part.set");
			case MORPHOSYNTACTIC_SPECS:
				return I18N.get("exportTable.part.msd3") + " " + I18N.get("exportTable.part.set");
			case MORPHOSYNTACTIC_PROPERTY:
				return I18N.get("exportTable.part.msdProperty3") + " " + I18N.get("exportTable.part.set");
			case WORD_TYPE:
				return I18N.get("exportTable.part.wordType3") + " " + I18N.get("exportTable.part.set");
			default:
				return null;
		}
	}
}
