Package ch.akuhn.hapax.linalg

Examples of ch.akuhn.hapax.linalg.Matrix


        Hapax hapax = Hapax.newCorpus()
        .useTFIDF()
        .useCamelCaseScanner()
        .addFiles(folder, ".java")
        .build();
        Matrix corr = hapax.getIndex().documentCorrelation();
        PrintWriter f = new PrintWriter("data.xml");
        f.println("<?xml version=\"1.0\"?>");
        f.println("<!DOCTYPE ggobidata SYSTEM \"ggobi.dtd\">");
        f.println("<ggobidata count=\"2\">");
        f.println("<data name=\"points\">");
        f.println("<variables count=\"1\">");
        f.println("  <realvariable name=\"x\" nickname=\"x\" />");
        f.println("</variables>");
        f.printf("<records count=\"%d\">\n", hapax.getIndex().documentCount());
        int n = 0;
        for (String doc: hapax.getIndex().documents()) {
            f.printf("<record id=\"%d\" label=\"%s\"> 0 </record>\n",
                    ++n,
                    new File(doc).getName());
        }
        f.print("</records>\n</data>\n\n");
        f.println("<data name=\"distance\">");
        f.println("<variables count=\"1\">");
        f.println("  <realvariable name=\"D\" nickname=\"D\" />");
        f.println("</variables>");
        int tally = 0;
        for (Vector row: corr.rows()) {
            for (Entry each: row.entries()) {
                if (Matrix.indexOf(row) >= each.index) continue;
                if (each.value > THRESHOLD) tally++;
            }
        }
        System.out.println(tally);
        f.printf("<records count=\"%d\" glyph=\"fr 1\" color=\"0\">\n", tally);
        for (Vector row: corr.rows()) {
            for (Entry each: row.entries()) {
                if (Matrix.indexOf(row) >= each.index) continue;
                if (each.value > THRESHOLD) {
                    f.printf("<record source=\"%d\" destination=\"%d\"> %f </record>\n",
                            Matrix.indexOf(row)+1,
View Full Code Here


        }
        return ranking.sort();
    }

    public Matrix documentCorrelation() {
        Matrix correlation = new SymetricMatrix(documents.size());
        for (int row: range(documents.size())) {
            for (int column: range(documents.size())) {
                correlation.put(row, column, svd.similarityVV(row, column));
            }
        }
        //Appendable file = Files.openWrite("document-correlation.json");
        //correlation.storeOn(file);
        //Files.close(file);
View Full Code Here

        //Files.close(file);
        return correlation;
    }
   
    public Matrix euclidianDistance() {
        Matrix dist = new SymetricMatrix(documents.size());
        for (int row: range(documents.size())) {
            for (int column: range(documents.size())) {
                dist.put(row, column, svd.euclidianVV(row, column));
            }
        }
        return dist;
    }
View Full Code Here

public class SymetricMatrixTest {

    @Test
    public void testPutGetIsSymetric() {
        Matrix m = new SymetricMatrix(5);
        m.put(4, 2, PI);
        assertEquals(PI, m.get(4, 2), Double.MIN_VALUE);
        assertEquals(PI, m.get(2, 4), Double.MIN_VALUE);
        m.put(3, 3, PI);
        assertEquals(PI, m.get(3, 3), Double.MIN_VALUE);
    }
View Full Code Here

TOP

Related Classes of ch.akuhn.hapax.linalg.Matrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.