<commit_before>package com.ayros.phonetowordsjava;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;

public class TestJava
{
	public static void main(String[] args)
	{
		PhoneToWordsDB db = PhoneToWordsDB.fromDictionary("test/resources/dictionary.txt");

		byte[] serializedDB = db.exportToBytes();

		writeBytesToFile("test/resources/ptw.db", serializedDB);

		serializedDB = readBytesFromFile("test/resources/ptw.db");

		db = PhoneToWordsDB.fromExported(serializedDB);
		PhoneToWords ptw = new PhoneToWords(db, 1);

		List<String> matches = ptw.getWords("74663686237");

		System.out.println("Found " + matches.size() + " matches:");
		for (String match : matches)
		{
			System.out.println(match);
		}
	}

	private static boolean writeBytesToFile(String fileName, byte[] data)
	{
		try
		{
			File outFile = new File(fileName);

			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile));
			bos.write(data);
			bos.flush();
			bos.close();

			return true;
		}
		catch (Exception e)
		{
			return false;
		}
	}

	private static byte[] readBytesFromFile(String fileName)
	{
		try
		{
			File inFile = new File(fileName);

			byte[] fileData = new byte[(int)inFile.length()];
			FileInputStream fis = new FileInputStream(inFile);
			fis.read(fileData);

			fis.close();

			return fileData;
		}
		catch (Exception e)
		{
			return null;
		}
	}
}<commit_msg>Updated test file to output times for different steps<commit_after>package com.ayros.phonetowordsjava;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.List;

public class TestJava
{
	private static long timer;
	
	public static void main(String[] args)
	{
		// Dictionary -> DB
		timerStart();
		PhoneToWordsDB db = PhoneToWordsDB.fromDictionary("test/resources/dictionary.txt");
		System.out.println("Constructed database from dictionary in " + timerMS() + "ms");
		
		// DB -> Serialized
		timerStart();
		byte[] serializedDB = db.exportToBytes();
		System.out.println("Serialized database in " + timerMS() + "ms");
		
		// Serialized -> File
		writeBytesToFile("test/resources/ptw.db", serializedDB);
		
		// File -> Serialized
		serializedDB = readBytesFromFile("test/resources/ptw.db");
		
		// Serialized -> DB
		timerStart();
		db = PhoneToWordsDB.fromExported(serializedDB);
		System.out.println("Unserialized database in " + timerMS() + "ms");
		
		// Create PhoneToWords
		PhoneToWords ptw = new PhoneToWords(db, 1);
		
		// Lookup number
		timerStart();
		List<String> matches = ptw.getWords("74663686237");
		System.out.println("Looked up number in " + timerMS() + "ms");
		
		System.out.println("Found " + matches.size() + " matches:");
		for (String match : matches)
		{
			System.out.println(match);
		}
	}
	
	private static void timerStart()
	{
		timer = System.nanoTime();
	}
	
	private static double timerMS()
	{
		return (System.nanoTime() - timer) / 1000000.0;
	}
	
	private static boolean writeBytesToFile(String fileName, byte[] data)
	{
		try
		{
			File outFile = new File(fileName);
			
			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile));
			bos.write(data);
			bos.flush();
			bos.close();
			
			return true;
		}
		catch (Exception e)
		{
			return false;
		}
	}
	
	private static byte[] readBytesFromFile(String fileName)
	{
		try
		{
			File inFile = new File(fileName);
			
			byte[] fileData = new byte[(int)inFile.length()];
			FileInputStream fis = new FileInputStream(inFile);
			fis.read(fileData);
			
			fis.close();
			
			return fileData;
		}
		catch (Exception e)
		{
			return null;
		}
	}
}
{'fraction_non_alphanumeric': 0.12900641025641027, 'fraction_numerical': 0.008547008547008548, 'mean_word_length': 3.789002557544757, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1361033', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1206, 'n_words': 271}