<commit_before>import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class ExtractTextFromFile {
	public static String getText(File inputFile, File outputFile) throws IOException {
		if (!inputFile.exists() || !inputFile.isFile()) {
			throw new IllegalArgumentException(inputFile.toString() + " is not a valid file");
		}
		
		// Use LibreOffice + unoconv to convert the document
		// /Applications/LibreOffice.app/Contents/MacOS/python ~/Downloads/unoconv-0.6/unoconv --format=text --output=testing.txt ~/Documents/testing.odt
		String args[] = new String[5];
		args[0] = "/Applications/LibreOffice.app/Contents/MacOS/python";
		args[1] = "/Users/ghelmer/Downloads/unoconv-0.6/unoconv";
		args[2] = "--format=text";
		args[3] = "--output=" + outputFile.getAbsolutePath();
		args[4] = inputFile.getAbsolutePath();
		Runtime r = Runtime.getRuntime();
		Process result = r.exec(args);
		Scanner in = new Scanner(result.getErrorStream());
		StringBuffer output = new StringBuffer();
		while (in.hasNextLine())
		{
			output.append(in.nextLine() + "\n");
		}
		in.close();
		try {
			result.waitFor();
			if (output.length() != 0)
			{
				System.out.println("Output form unoconv " + inputFile.getAbsolutePath() + " to " + outputFile.getAbsolutePath() + ":");
				System.out.println(output);
			}
			else if (result.exitValue() != 0)
			{
				System.out.println("unoconv exit code: " + result.exitValue());
			}
		} catch (InterruptedException e) {
			System.err.println("unoconv Interrupted Exception: " + e.getMessage());
		}
		return "The file " + inputFile.getName() + " contains:\n";
	}
}<commit_msg>Switch back to OpenOffice to extract text from files. LibreOffice 4.4 raised too many challenges for continued use with unoconv.<commit_after>import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class ExtractTextFromFile {
	public static String getText(File inputFile, File outputFile) throws IOException {
		if (!inputFile.exists() || !inputFile.isFile()) {
			throw new IllegalArgumentException(inputFile.toString() + " is not a valid file");
		}
		
		// Use OpenOffice.app + unoconv to convert the document.
		// unoconv no longer works with LibreOffice.
		// /usr/bin/python ~/Downloads/unoconv-0.6/unoconv --format=text --output=testing.txt ~/Documents/testing.odt
		String args[] = new String[5];
		args[0] = "/usr/bin/python";
		args[1] = "/Users/ghelmer/Downloads/unoconv-0.6/unoconv";
		args[2] = "--format=text";
		args[3] = "--output=" + outputFile.getAbsolutePath();
		args[4] = inputFile.getAbsolutePath();
		Runtime r = Runtime.getRuntime();
		Process result = r.exec(args);
		Scanner in = new Scanner(result.getErrorStream());
		StringBuffer output = new StringBuffer();
		while (in.hasNextLine())
		{
			output.append(in.nextLine() + "\n");
		}
		in.close();
		try {
			result.waitFor();
			if (output.length() != 0)
			{
				System.out.println("Output form unoconv " + inputFile.getAbsolutePath() + " to " + outputFile.getAbsolutePath() + ":");
				System.out.println(output);
			}
			else if (result.exitValue() != 0)
			{
				System.out.println("unoconv exit code: " + result.exitValue());
			}
		} catch (InterruptedException e) {
			System.err.println("unoconv Interrupted Exception: " + e.getMessage());
		}
		return "The file " + inputFile.getName() + " contains:\n";
	}
}
{'fraction_non_alphanumeric': 0.15792610250297973, 'fraction_numerical': 0.0077473182359952325, 'mean_word_length': 3.9150805270863835, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7193639', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1094, 'n_words': 239}