public static void main(String[] args) throws Exception { String logConfig = System.getProperty("log-config"); if (logConfig == null) { logConfig = "log-config.txt"; } long begin = System.currentTimeMillis(); PropertyConfigurator.configure(logConfig); if (args.length != 2) { System.out.println("Usage: java -mx1024M eu.fbk.utils.lsa.InverseVocabulary row df"); System.exit(1); } File row = new File(args[0]); File df = new File(args[1]); InverseVocabulary inverseVocabulary = new InverseVocabulary(row, df); inverseVocabulary.interactive(); } // end main
public void interactive() throws Exception { InputStreamReader reader = null; BufferedReader myInput = null; while (true) { System.out.println("\nPlease write a term index and type <return> to continue (CTRL C to exit):"); reader = new InputStreamReader(System.in); myInput = new BufferedReader(reader); //String query = myInput.readLine().toString().replace(' ', '_'); String query = myInput.readLine().toString(); logger.info("page"); int i = Integer.parseInt(query); int f = get(i); logger.info("f(" + i + ") = " + f); } // end while } // end
public InverseVocabulary(File row, File df) throws IOException { map = new HashMap<Integer, Integer>(); read(row, df); } // end constructor
/** * Constructs a sparse binary matrix writer. * * @param file the file where to write the matrix. */ public TFIDF(File in, File out, File row, File df) throws IOException { inRAF = new RandomAccessFile(in, "r"); outRAF = new RandomAccessFile(out, "rw"); channel = inRAF.getChannel(); inverseVocabulary = new InverseVocabulary(row, df); nr = 0; nc = 0; nz = 0; readHeader(); writeHeader(); if (nr != inverseVocabulary.size()) { logger.error(nr + " != " + inverseVocabulary); System.exit(-1); } convert(); close(); } // end constructor
float df = (float) Math.log10((double) nc / (1 + inverseVocabulary.get(j)));