ilteris kaplan blog

Jackson Mac Low's Diastic Algorithm

January 22, 2006

I have been trying to implement Jackson Mac Low’s diastic readings[link] in Java for an exercise this week. I managed to work the algorithm partly, I can choose a phrase before compile and spit out the words according to it that my program reads from an input file. Couple of things are missing though;

`

// *************** DIASTIC TEXT ALGORITHM ****************
// Bugs: There is this repetition of the i after
// it finds the phrase character, could be a problem
// if the phrase has double char like "book".
// also i doesn't goes up to the last element.
// *******************************************************
// to do: use lines according to the marks.
// make it look more like a poem.
// *******************************************************

import java.io.*;
import java.nio.*;
import java.nio.channels.*;

public class Diasticc {
    public static void main (String[] args) throws IOException {
        FileInputStream fis = new FileInputStream(args[0]);
        FileChannel fc = fis.getChannel();
        ByteBuffer bb = ByteBuffer.allocate((int)fc.size());
        fc.read(bb);
        fc.close();
         
       
        String content = new String(bb.array());
        String phrase="poem";
        String[] word = content.split(" ");
        int i = 0;
        for (int k=0; k < phrase.length(); k++) {
            for ( i = i + 1; i                 if(i >= word.length-1) {
                    i = 0;
                }
                //System.out.println(i);
                if(word[i].length() > k) {
                if(word[i].charAt(k) == phrase.charAt(k)) {
                   // System.out.println(i + " " + word[i]);
                   // System.out.println(k + " " + phrase.charAt(k));
                   System.out.println(word[i]);
                    
                    
                    break;
                }
            }
        }
        }
      }
}

`


Written by Ilteris Kaplan who still lives and works in New York. Twitter