src/main/java/org/thegalactic/context/io/ContextSerializerSLF.java
public void read(Context context, BufferedReader file) throws IOException {

        ArrayList<Comparable> obs = new ArrayList();
        ArrayList<Comparable> att = new ArrayList();

        TreeMap<Comparable, TreeSet<Comparable>> intent = new TreeMap();
        TreeMap<Comparable, TreeSet<Comparable>> extent = new TreeMap();

        if (!file.readLine().equals("[Lattice]")) {
            throw new IOException("Misformated SLF file.");
        }
        int nbObs = Integer.parseInt(file.readLine());
        int nbAtt = Integer.parseInt(file.readLine());

        if (!file.readLine().equals("[Objects]")) {
            throw new IOException("Misformated SLF file.");
        }
        String line = file.readLine();
        while (!"[Attributes]".equals(line)) {
            obs.add(line);
            intent.put(line, new TreeSet());
            line = file.readLine();
        }
        line = file.readLine();
        while (!"[relation]".equals(line)) {
            att.add(line);
            extent.put(line, new TreeSet());
            line = file.readLine();
        }

        context.addAllToAttributes(new TreeSet(att));
        context.addAllToObservations(new TreeSet(obs));

        for (int i = 0; i < nbObs; i++) {
            line = file.readLine();
            StringTokenizer st = new StringTokenizer(line);
            int cpt = 0;
            while (st.hasMoreTokens()) {
                String n = st.nextToken();
                if ("1".equals(n)) {
                    context.addExtentIntent(obs.get(i), att.get(cpt));
                }
                cpt++;
            }
            if (cpt != nbAtt) {
                throw new IOException("Misformated SLF file.");
            }
        }
        context.setBitSets();
    }
/**
     * Read a context from a file.
     *
     * The following format is respected:
     *
     * The number of objects and observation on two separated lines The list of
     * objects on seprated lines The list of attributes on separated lines
     *
     * then, for each observations, the list of its intent on a line, written
     * like 0 1 0
     *
     * ~~~
     * [Lattice]
     * 2
     * 3
     * [Objects]
     * 1 2
     * [Attributes]
     * a b c
     * [relation]
     * 0 1 0
     * 1 1 0
     * ~~~
     *
     * @param context a context to read
     * @param file    a file
     *
     * @throws IOException When an IOException occurs
     */
Read a context from a file.
The following format is respected.

The number of objects and observation on two separated lines The list of
objects on seprated lines The list of attributes on separated lines

then, for each observations, the list of its intent on a line, written
like 0 1 0



@param context a context to read
@param file    a file


Read a context from a file . The following format is respected . The number of objects and observation on two separated lines The list of objects on seprated lines The list of attributes on separated lines then for each observations the list of its intent on a line written like 0 1 0 @param context a context to read @param file a file
public void read(Context context, BufferedReader file) throws IOException {
        ArrayList<Comparable> obs = new ArrayList();
        ArrayList<Comparable> att = new ArrayList();
        TreeMap<Comparable, TreeSet<Comparable>> intent = new TreeMap();
        TreeMap<Comparable, TreeSet<Comparable>> extent = new TreeMap();
        if (!file.readLine().equals("[Lattice]")) {
            throw new IOException("Misformated SLF file.");
        }
        int nbObs = Integer.parseInt(file.readLine());
        int nbAtt = Integer.parseInt(file.readLine());
        if (!file.readLine().equals("[Objects]")) {
            throw new IOException("Misformated SLF file.");
        }
        String line = file.readLine();
        while (!"[Attributes]".equals(line)) {
            obs.add(line);
            intent.put(line, new TreeSet());
            line = file.readLine();
        }
        line = file.readLine();
        while (!"[relation]".equals(line)) {
            att.add(line);
            extent.put(line, new TreeSet());
            line = file.readLine();
        }
        context.addAllToAttributes(new TreeSet(att));
        context.addAllToObservations(new TreeSet(obs));
        for (int i = 0; i < nbObs; i++) {
            line = file.readLine();
            StringTokenizer st = new StringTokenizer(line);
            int cpt = 0;
            while (st.hasMoreTokens()) {
                String n = st.nextToken();
                if ("1".equals(n)) {
                    context.addExtentIntent(obs.get(i), att.get(cpt));
                }
                cpt++;
            }
            if (cpt != nbAtt) {
                throw new IOException("Misformated SLF file.");
            }
        }
        context.setBitSets();
    }
public void read ( Context context , BufferedReader file ) throws IOException { ArrayList < Comparable > obs = new ArrayList ( ) ; ArrayList < Comparable > att = new ArrayList ( ) ; TreeMap < Comparable , TreeSet < Comparable > > intent = new TreeMap ( ) ; TreeMap < Comparable , TreeSet < Comparable > > extent = new TreeMap ( ) ; if ( ! file . readLine ( ) . equals ( "[Lattice]" ) ) { throw new IOException ( "Misformated SLF file." ) ; } int nbObs = Integer . parseInt ( file . readLine ( ) ) ; int nbAtt = Integer . parseInt ( file . readLine ( ) ) ; if ( ! file . readLine ( ) . equals ( "[Objects]" ) ) { throw new IOException ( "Misformated SLF file." ) ; } String line = file . readLine ( ) ; while ( ! "[Attributes]" . equals ( line ) ) { obs . add ( line ) ; intent . put ( line , new TreeSet ( ) ) ; line = file . readLine ( ) ; } line = file . readLine ( ) ; while ( ! "[relation]" . equals ( line ) ) { att . add ( line ) ; extent . put ( line , new TreeSet ( ) ) ; line = file . readLine ( ) ; } context . addAllToAttributes ( new TreeSet ( att ) ) ; context . addAllToObservations ( new TreeSet ( obs ) ) ; for ( int i = 0 ; i < nbObs ; i ++ ) { line = file . readLine ( ) ; StringTokenizer st = new StringTokenizer ( line ) ; int cpt = 0 ; while ( st . hasMoreTokens ( ) ) { String n = st . nextToken ( ) ; if ( "1" . equals ( n ) ) { context . addExtentIntent ( obs . get ( i ) , att . get ( cpt ) ) ; } cpt ++ ; } if ( cpt != nbAtt ) { throw new IOException ( "Misformated SLF file." ) ; } } context . setBitSets ( ) ; }
Read a context from a file.
Read a context from a file .