package models;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.Model;

@Entity
@Table(name="word")
public class Word extends Model {

	private static final long serialVersionUID = 1L;

	@Id
    private long id;
	
	@Constraints.Required
    @Formats.NonEmpty
    private String normalizedValue;
	
	private int showedCount;
	
	private int unknownCount;
	
	// -- Queries

    public static Model.Finder<String, Word> find = new Model.Finder<String, Word>(String.class, Word.class);

    public static List<Word> findAll() {
        return find.all();
    }
    
    public static Word findByValue(String word) {
        return find.where().eq("normalizedValue", word).findUnique();
    }
    
    public static void updateAll(List<Word> words) {
        for (Word word : words) {
        	word.update();
		}
    }
    
    // getters and setters

    
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getNormalizedValue() {
		return normalizedValue;
	}
	public void setNormalizedValue(String normalizedValue) {
		this.normalizedValue = normalizedValue;
	}
	public int getShowedCount() {
		return showedCount;
	}
	public void setShowedCount(int showedCount) {
		this.showedCount = showedCount;
	}
	public int getUnknownCount() {
		return unknownCount;
	}
	public void setUnknownCount(int unknownCount) {
		this.unknownCount = unknownCount;
	}
	
}

@@ -27,20 +27,68 @@
 va.util.
-List
+HashMap;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0A%0Aimpor
@@ -760,32 +760,477 @@
 l();%0A    %7D%0A    %0A
+    public static Map%3CString, Double%3E getWordStatistics() %7B%0A    %09Map%3CString, Double%3E result = new HashMap%3CString, Double%3E();%0A        List%3CWord%3E all = find.all();%0A        for (Word word : all) %7B%0A        %09Double coef = Double.valueOf(0.0);%0A%09%09%09if (word.getShowedCount() != 0) %7B%0A%09%09%09%09coef = (double) (word.getUnknownCount() / (double) word.getShowedCount());%0A%09%09%09%7D%0A%09%09%09result.put(word.getNormalizedValue(), coef);%0A%09%09%7D%0A        return result;%0A    %7D%0A    %0A
     public stati

add getWordStatistics