// Path: src/main/java/com/globalsight/ling/tm3/core/TM3Data.java
// public interface TM3Data {
//     
//     /**
//      * Return the data as a stream of tokens.  The fuzzy matching system
//      * will bracket this stream with boundary tokens indicating the start
//      * and end of the segment.
//      * 
//      * @return {@link Iterable} capable of producing the token stream
//      */
//     public Iterable<Long> tokenize();
// 
//     /**
//      * Compute and return the data's fingerprint. 
//      */
//     public long getFingerprint();
//     
//     /**
//      * Serialize this TUV data for storage.  This form should be deserializable
//      * by a corresponding {@link TM3DataFactory} implementation.
//      */
//     public String getSerializedForm();
// 
//     /**
//      * Test object equality.
//      * <p>"Equality" in this case may be as simple as a string compare,
//      * or there may be more complicated logical comparisons going on.
//      * <b>Warning:</b> Implementations <b>must</b> override <tt>equals()</tt>
//      * or else run the risk of duplicate target TUVs being persisted in the 
//      * database.  
//      * @param o object to test for equality
//      * @return true if the objects are equal; false otherwise
//      */
//     @Override
//     public boolean equals(Object o);
// }


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.globalsight.ling.tm3.core.TM3Data;
package com.globalsight.ling.tm3.core;



class Trigrammer {

    // Start/end of segment boundary
    private static final Long BOUNDARY = -1l; 

    static class Trigram {
        long[] fingerprints;

        public Trigram(Long fp0, Long fp1, Long fp2) {
            fingerprints = new long[3];
            fingerprints[0] = fp0.longValue();
            fingerprints[1] = fp1.longValue();
            fingerprints[2] = fp2.longValue();
        }

        public String toString() {
            return Arrays.toString(fingerprints);
        }
        
        public Long getValue() {
            return fingerprints[0] + 31 *
                        (fingerprints[1] + 31 * fingerprints[2]);
        }

    }
	
    Trigrammer() {
    }

    // Like everything else, this is a slapdash affair.  There's lots of 
    // normalization I would normally use.
// Path: src/main/java/com/globalsight/ling/tm3/core/TM3Data.java
// public interface TM3Data {
//     
//     /**
//      * Return the data as a stream of tokens.  The fuzzy matching system
//      * will bracket this stream with boundary tokens indicating the start
//      * and end of the segment.
//      * 
//      * @return {@link Iterable} capable of producing the token stream
//      */
//     public Iterable<Long> tokenize();
// 
//     /**
//      * Compute and return the data's fingerprint. 
//      */
//     public long getFingerprint();
//     
//     /**
//      * Serialize this TUV data for storage.  This form should be deserializable
//      * by a corresponding {@link TM3DataFactory} implementation.
//      */
//     public String getSerializedForm();
// 
//     /**
//      * Test object equality.
//      * <p>"Equality" in this case may be as simple as a string compare,
//      * or there may be more complicated logical comparisons going on.
//      * <b>Warning:</b> Implementations <b>must</b> override <tt>equals()</tt>
//      * or else run the risk of duplicate target TUVs being persisted in the 
//      * database.  
//      * @param o object to test for equality
//      * @return true if the objects are equal; false otherwise
//      */
//     @Override
//     public boolean equals(Object o);
// }


// Path: src/main/java/com/globalsight/ling/tm3/core/Trigrammer.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.globalsight.ling.tm3.core.TM3Data;

package com.globalsight.ling.tm3.core;



class Trigrammer {

    // Start/end of segment boundary
    private static final Long BOUNDARY = -1l; 

    static class Trigram {
        long[] fingerprints;

        public Trigram(Long fp0, Long fp1, Long fp2) {
            fingerprints = new long[3];
            fingerprints[0] = fp0.longValue();
            fingerprints[1] = fp1.longValue();
            fingerprints[2] = fp2.longValue();
        }

        public String toString() {
            return Arrays.toString(fingerprints);
        }
        
        public Long getValue() {
            return fingerprints[0] + 31 *
                        (fingerprints[1] + 31 * fingerprints[2]);
        }

    }
	
    Trigrammer() {
    }

    // Like everything else, this is a slapdash affair.  There's lots of 
    // normalization I would normally use.
    List<Trigram> getTrigrams(TM3Data data) {