public static void writeSentencesToDirectories(
			ArrayList<Sentence> sentences, String directory) throws IOException {
		File dir = new File(directory);
		File posDir = new File(directory + "/pos");
		File negDir = new File(directory + "/neg");
		File allDir = new File(directory + "/all");
		if (dir.exists()) {
			if (!posDir.exists())
				posDir.mkdir();
			if (!negDir.exists())
				negDir.mkdir();
			if (!allDir.exists())
				allDir.mkdir();
		} else
			throw new IOException("Directory doesn't exist");

		for (int i = 1; i < sentences.size(); i++) {
			Sentence s = sentences.get(i);

			BufferedWriter writer = new BufferedWriter(new FileWriter(new File(
					allDir + "/" + i + ".txt"), false));
			writer.write(s.sentence);
			writer.close();
		}

		for (int i = 1; i <= sentences.size(); i++) {
			Sentence s = sentences.get(i);

			String message = s.sentence;
			if (JOptionPane.showOptionDialog(null, message,
					"Remaining sentences: " + (sentences.size() - i)
							+ " Does this sentence contain a goal?",
					JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
					null, null, null) == JOptionPane.YES_OPTION) {
				BufferedWriter writer = new BufferedWriter(new FileWriter(
						new File(posDir + "/" + i + ".txt"), false));
				writer.write(s.sentence);
				writer.close();
			} else {
				BufferedWriter writer = new BufferedWriter(new FileWriter(
						new File(negDir + "/" + i + ".txt"), false));
				writer.write(s.sentence);
				writer.close();
			}

		}
	}