src/main/java/org/thegalactic/context/io/ContextSerializerBurmeister.java
public void read(final Context context, final BufferedReader file) throws IOException {
        // str corresponds to the string "B". First line (Unused).
        String str = file.readLine();

        // Detect Burmeister magic header
        if (!HEADER.equals(str)) {
            throw new IOException("Burmeister magic header not found");
        }

        // Second line (Unused in the code).
        file.readLine();

        try {
            // number of observations. Third line.
            final int nbObs = Integer.parseInt(file.readLine());

            // number of attributes. Fourth line.
            final int nbAtt = Integer.parseInt(file.readLine());

            // Now reading observations
            // Observations names must be recorded for the reading context phase
            String[] obsNames = new String[nbObs];
            for (int i = 0; i < nbObs; i++) {
                obsNames[i] = this.readNextLine(file);
                context.addToObservations(obsNames[i]);
            }

            // Now reading attributes
            // Attributes names must be recorded for the reading context phase
            String[] attNames = new String[nbAtt];
            for (int i = 0; i < nbAtt; i++) {
                attNames[i] = this.readNextLine(file);
                context.addToAttributes(attNames[i]);
            }

            // Now reading context
            for (int i = 0; i < nbObs; i++) {
                str = this.readNextLine(file);
                for (int j = 0; j < nbAtt; j++) {
                    if (str.charAt(j) == 'X') {
                        context.addExtentIntent(obsNames[i], attNames[j]);
                    }
                }
            }
            context.setBitSets();
        } catch (NumberFormatException ex) {
            throw new IOException(ex.getMessage());
        } catch (IndexOutOfBoundsException ex) {
            throw new IOException(ex.getMessage());
        }
    }
/**
     * Read a context from a file.
     *
     * The Burmeister cxt format file is respected :
     *
     * The file format is structured as follows:
     *
     * The first line consists of a single "B"
     * The second line contains the name of the context (note that this is
     * ignored)
     * The third and fourth line consist of the object and attribute count,
     * respectively
     * after that, all objects and all attributes are listed, each on a separate
     * line
     * finally, the context is given as a combination of . and X, each row on a
     * separate line.
     *
     * ~~~
     * B
     * Example
     * 2
     * 2
     * a
     * b
     * 1
     * 2
     * .X
     * XX
     * ~~~
     *
     * @param context a context to read
     * @param file    a file
     *
     * @throws IOException When an IOException occurs
     */
Read a context from a file.
The Burmeister cxt format file is respected .

The file format is structured as follows.

The first line consists of a single "B"
The second line contains the name of the context (note that this is
ignored)
The third and fourth line consist of the object and attribute count,
respectively
after that, all objects and all attributes are listed, each on a separate
line
finally, the context is given as a combination of . and X, each row on a
separate line.



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


Read a context from a file . The Burmeister cxt format file is respected . The file format is structured as follows . The first line consists of a single " B " The second line contains the name of the context ( note that this is ignored ) The third and fourth line consist of the object and attribute count respectively after that all objects and all attributes are listed each on a separate line finally the context is given as a combination of . and X each row on a separate line . @param context a context to read @param file a file
public void read(final Context context, final BufferedReader file) throws IOException {
        String str = file.readLine();
        if (!HEADER.equals(str)) {
            throw new IOException("Burmeister magic header not found");
        }
        file.readLine();
        try {
            final int nbObs = Integer.parseInt(file.readLine());
            final int nbAtt = Integer.parseInt(file.readLine());
            String[] obsNames = new String[nbObs];
            for (int i = 0; i < nbObs; i++) {
                obsNames[i] = this.readNextLine(file);
                context.addToObservations(obsNames[i]);
            }
            String[] attNames = new String[nbAtt];
            for (int i = 0; i < nbAtt; i++) {
                attNames[i] = this.readNextLine(file);
                context.addToAttributes(attNames[i]);
            }
            for (int i = 0; i < nbObs; i++) {
                str = this.readNextLine(file);
                for (int j = 0; j < nbAtt; j++) {
                    if (str.charAt(j) == 'X') {
                        context.addExtentIntent(obsNames[i], attNames[j]);
                    }
                }
            }
            context.setBitSets();
        } catch (NumberFormatException ex) {
            throw new IOException(ex.getMessage());
        } catch (IndexOutOfBoundsException ex) {
            throw new IOException(ex.getMessage());
        }
    }
public void read ( final Context context , final BufferedReader file ) throws IOException { String str = file . readLine ( ) ; if ( ! HEADER . equals ( str ) ) { throw new IOException ( "Burmeister magic header not found" ) ; } file . readLine ( ) ; try { final int nbObs = Integer . parseInt ( file . readLine ( ) ) ; final int nbAtt = Integer . parseInt ( file . readLine ( ) ) ; String [ ] obsNames = new String [ nbObs ] ; for ( int i = 0 ; i < nbObs ; i ++ ) { obsNames [ i ] = this . readNextLine ( file ) ; context . addToObservations ( obsNames [ i ] ) ; } String [ ] attNames = new String [ nbAtt ] ; for ( int i = 0 ; i < nbAtt ; i ++ ) { attNames [ i ] = this . readNextLine ( file ) ; context . addToAttributes ( attNames [ i ] ) ; } for ( int i = 0 ; i < nbObs ; i ++ ) { str = this . readNextLine ( file ) ; for ( int j = 0 ; j < nbAtt ; j ++ ) { if ( str . charAt ( j ) == 'X' ) { context . addExtentIntent ( obsNames [ i ] , attNames [ j ] ) ; } } } context . setBitSets ( ) ; } catch ( NumberFormatException ex ) { throw new IOException ( ex . getMessage ( ) ) ; } catch ( IndexOutOfBoundsException ex ) { throw new IOException ( ex . getMessage ( ) ) ; } }
Read a context from a file.
Read a context from a file .
// str corresponds to the string "B". First line (Unused). // Detect Burmeister magic header // Second line (Unused in the code). // number of observations. Third line. // number of attributes. Fourth line. // Now reading observations // Observations names must be recorded for the reading context phase // Now reading attributes // Attributes names must be recorded for the reading context phase // Now reading context