src/main/java/org/thegalactic/context/io/ContextSerializerSLF.java
public void write(Context context, BufferedWriter file) throws IOException {
        ArrayList<Comparable> obs = new ArrayList(context.getObservations());
        ArrayList<Comparable> att = new ArrayList(context.getAttributes());
        file.write("[Lattice]");
        file.newLine();
        file.write(String.valueOf(context.getObservations().size()));
        file.newLine();
        file.write(String.valueOf(context.getAttributes().size()));
        file.newLine();
        file.write("[Objects]");
        file.newLine();
        for (Comparable o : obs) {
            file.write((String) o);
            file.newLine();
        }
        file.write("[Attributes]");
        file.newLine();
        for (Comparable a : att) {
            file.write((String) a);
            file.newLine();
        }
        file.write("[relation]");
        file.newLine();
        for (Comparable o : obs) {
            TreeSet<Comparable> intent = context.getIntent(o);
            for (Comparable a : att) {
                if (intent.contains(a)) {
                    file.write("1 ");
                } else {
                    file.write("0 ");
                }
            }
            file.newLine();
        }
    }
/**
     * Write a context to a file.
     *
     * The Standard Lattice Format SLF format file is respected :
     *
     * 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 write
     * @param file    a file
     *
     * @throws IOException When an IOException occurs
     */
Write a context to a file.
The Standard Lattice Format SLF format file is respected .

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 write
@param file    a file


Write a context to a file . The Standard Lattice Format SLF format file is respected . 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 write @param file a file
public void write(Context context, BufferedWriter file) throws IOException {
        ArrayList<Comparable> obs = new ArrayList(context.getObservations());
        ArrayList<Comparable> att = new ArrayList(context.getAttributes());
        file.write("[Lattice]");
        file.newLine();
        file.write(String.valueOf(context.getObservations().size()));
        file.newLine();
        file.write(String.valueOf(context.getAttributes().size()));
        file.newLine();
        file.write("[Objects]");
        file.newLine();
        for (Comparable o : obs) {
            file.write((String) o);
            file.newLine();
        }
        file.write("[Attributes]");
        file.newLine();
        for (Comparable a : att) {
            file.write((String) a);
            file.newLine();
        }
        file.write("[relation]");
        file.newLine();
        for (Comparable o : obs) {
            TreeSet<Comparable> intent = context.getIntent(o);
            for (Comparable a : att) {
                if (intent.contains(a)) {
                    file.write("1 ");
                } else {
                    file.write("0 ");
                }
            }
            file.newLine();
        }
    }
public void write ( Context context , BufferedWriter file ) throws IOException { ArrayList < Comparable > obs = new ArrayList ( context . getObservations ( ) ) ; ArrayList < Comparable > att = new ArrayList ( context . getAttributes ( ) ) ; file . write ( "[Lattice]" ) ; file . newLine ( ) ; file . write ( String . valueOf ( context . getObservations ( ) . size ( ) ) ) ; file . newLine ( ) ; file . write ( String . valueOf ( context . getAttributes ( ) . size ( ) ) ) ; file . newLine ( ) ; file . write ( "[Objects]" ) ; file . newLine ( ) ; for ( Comparable o : obs ) { file . write ( ( String ) o ) ; file . newLine ( ) ; } file . write ( "[Attributes]" ) ; file . newLine ( ) ; for ( Comparable a : att ) { file . write ( ( String ) a ) ; file . newLine ( ) ; } file . write ( "[relation]" ) ; file . newLine ( ) ; for ( Comparable o : obs ) { TreeSet < Comparable > intent = context . getIntent ( o ) ; for ( Comparable a : att ) { if ( intent . contains ( a ) ) { file . write ( "1 " ) ; } else { file . write ( "0 " ) ; } } file . newLine ( ) ; } }
Write a context to a file.
Write a context to a file .