import java.util.*;
import java.io.*;

class Concordance1 {
	Concordance1(String fname) throws IOException {
		BufferedReader br =
			new BufferedReader(new InputStreamReader(new FileInputStream(fname)));
		String line = br.readLine();
		while (line != null) {
			Vector words = parse(line);
			for (Iterator iter = words.iterator(); iter.hasNext(); ) {
				String word = (String)iter.next();
				add(word);				
			}
			line = br.readLine();
		}
	}

	private Vector parse(String line) {
		Vector result = new Vector();
		line = line.trim();
		int strPos = 0; 
		while (strPos < line.length())
			if (Character.isLetter(line.charAt(strPos))) {
				String word = "";
				while (strPos < line.length() && Character.isLetter(line.charAt(strPos))) {
					word += line.charAt(strPos);
					strPos++;
				}
				result.add(word);
			}
			else
				strPos++;
		return result;
	}

	private void add(String word) {
		if (map.get(word) == null)
			map.put(word, new Integer(1));
		else {
			int freq = ((Integer)map.get(word)).intValue() + 1;
			map.put(word, new Integer(freq));
		}
	}

	public String toString() {
		String result = "";
		for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
			String word = (String)iter.next();
			result += word + ": " + map.get(word) + "\n";
		}
		return result;
	}

	public static void main(String [] args) throws Exception {
		Concordance c = new Concordance("Concordance.java");
		System.out.println("The Concordance:\n----------------\n" + c);
	}

	TreeMap map = new TreeMap();
}