import java.io.*;
import java.util.*;
class Indexeur {
public static void main(String[] args) {
try {
Reader r=new FileReader(args[0]);
StreamTokenizer st=new StreamTokenizer (r);
st.whitespaceChars('.','.') ;
st.eolIsSignificant(true); // on veut reconnaitre les fins de ligne
Map index = new TreeMap();
int noLigne = 1;
while (st.nextToken()!=st.TT_EOF) {
if (st.ttype == st.TT_EOL) noLigne++;
if (st.ttype== st.TT_WORD) {
List lignes = (List)index.get(st.sval);
if (lignes == null) {
// premiere fois qu'on trouve ce mot
lignes = new ArrayList();
index.put(st.sval, lignes);
}
lignes.add(new Integer(noLigne));
}
} // while
r.close();
// Parcours de toutes les cles de la fonction
Iterator i = index.keySet().iterator();
while (i.hasNext()) {
Object mot = i.next();
System.out.print((String)mot);
List lignes = (List)index.get(mot);
// Parcours de la liste des nos de lignes
Iterator j = lignes.iterator();
while (j.hasNext()) {
int ligne = ( (Integer)j.next() ).intValue();
System.out.print(" " + ligne);
}
System.out.println();
}
}
catch (FileNotFoundException e) {System.out.println("Fichier non trouve");}
catch (IOException e) {System.out.println("Erreur de lecture");}
}
}