src/main/java/org/thegalactic/lattice/io/ImplicationalSystemSerializerText.java
public void read(ImplicationalSystem system, BufferedReader file) throws IOException {
        // first line : All elements of S separated by a space
        // a StringTokenizer is used to divide the line into different token,
        // considering spaces as separator.
        StringTokenizer st = new StringTokenizer(file.readLine());
        while (st.hasMoreTokens()) {
            String n = new String(st.nextToken());
            system.addElement(n);
        }
        // next lines : [elements of the premise separated by a space] -> [elements of the conclusion separated by a space]
        // a StringTokenizer is used to divide each rule.
        String line = file.readLine();
        while (line != null && !line.isEmpty()) {
            st = new StringTokenizer(line);
            Rule r = new Rule();
            boolean prem = true;
            while (st.hasMoreTokens()) {
                String word = st.nextToken();
                if ("->".equals(word)) {
                    prem = false;
                } else {
                    String x = null;
                    // search of x in S
                    for (Comparable e : system.getSet()) {
                        if (((String) e).equals(word)) {
                            x = (String) e;
                        }
                    }
                    if (x != null) {
                        if (prem) {
                            r.addToPremise(x);
                        } else {
                            r.addToConclusion(x);
                        }
                    }
                }
            }
            if (!r.getConclusion().isEmpty()) {
                system.addRule(r);
            }
            line = file.readLine();
        }
    }
/**
     * Saves this component in a file.
     *
     * The following format is used:
     *
     * An implicational system can be instancied from and save to a text file in
     * the following format: A list of elements separated by a space in the
     * first line ; then, each rule on a line, written like [premise] ->
     * [conclusion] where elements are separated by a space.
     *
     * ~~~
     * a b c d e
     * a b -> c d
     * c d -> e
     * ~~~
     *
     * @param system a system to read
     * @param file   a file
     *
     * @throws IOException When an IOException occurs
     */
Saves this component in a file.
The following format is used.

An implicational system can be instancied from and save to a text file in
the following format: A list of elements separated by a space in the
first line ; then, each rule on a line, written like [premise] ->
[conclusion] where elements are separated by a space.



@param system a system to read
@param file   a file


Saves this component in a file . The following format is used . An implicational system can be instancied from and save to a text file in the following format : A list of elements separated by a space in the first line ; then each rule on a line written like [ premise ] - > [ conclusion ] where elements are separated by a space . @param system a system to read @param file a file
public void read(ImplicationalSystem system, BufferedReader file) throws IOException {
        StringTokenizer st = new StringTokenizer(file.readLine());
        while (st.hasMoreTokens()) {
            String n = new String(st.nextToken());
            system.addElement(n);
        }
        String line = file.readLine();
        while (line != null && !line.isEmpty()) {
            st = new StringTokenizer(line);
            Rule r = new Rule();
            boolean prem = true;
            while (st.hasMoreTokens()) {
                String word = st.nextToken();
                if ("->".equals(word)) {
                    prem = false;
                } else {
                    String x = null;
                    for (Comparable e : system.getSet()) {
                        if (((String) e).equals(word)) {
                            x = (String) e;
                        }
                    }
                    if (x != null) {
                        if (prem) {
                            r.addToPremise(x);
                        } else {
                            r.addToConclusion(x);
                        }
                    }
                }
            }
            if (!r.getConclusion().isEmpty()) {
                system.addRule(r);
            }
            line = file.readLine();
        }
    }
public void read ( ImplicationalSystem system , BufferedReader file ) throws IOException { StringTokenizer st = new StringTokenizer ( file . readLine ( ) ) ; while ( st . hasMoreTokens ( ) ) { String n = new String ( st . nextToken ( ) ) ; system . addElement ( n ) ; } String line = file . readLine ( ) ; while ( line != null && ! line . isEmpty ( ) ) { st = new StringTokenizer ( line ) ; Rule r = new Rule ( ) ; boolean prem = true ; while ( st . hasMoreTokens ( ) ) { String word = st . nextToken ( ) ; if ( "->" . equals ( word ) ) { prem = false ; } else { String x = null ; for ( Comparable e : system . getSet ( ) ) { if ( ( ( String ) e ) . equals ( word ) ) { x = ( String ) e ; } } if ( x != null ) { if ( prem ) { r . addToPremise ( x ) ; } else { r . addToConclusion ( x ) ; } } } } if ( ! r . getConclusion ( ) . isEmpty ( ) ) { system . addRule ( r ) ; } line = file . readLine ( ) ; } }
Saves this component in a file.
Saves this component in a file .
// first line : All elements of S separated by a space // a StringTokenizer is used to divide the line into different token, // considering spaces as separator. // next lines : [elements of the premise separated by a space] -> [elements of the conclusion separated by a space] // a StringTokenizer is used to divide each rule. // search of x in S