<commit_before>package com.n9mtq4.botclient

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.net.Socket

/**
 * Created by will on 11/27/15 at 11:16 PM.
 *
 * Handles all the client to server connections
 *
 * @author Will "n9Mtq4" Bresnahan
 */
class ServerConnection(val port: Int) {
	
	internal val client: Socket
	internal val input: BufferedReader
	internal val output: PrintWriter
	
	init {
		println("Connecting to server...")
		this.client = Socket("localhost", port)
		this.input = BufferedReader(InputStreamReader(client.inputStream))
		this.output = PrintWriter(client.outputStream, true)
		println("Successfully connected to server")
	}
	
	/**
	 * Reads only one line from the server/
	 *
	 * @return a single line of data
	 * */
	internal fun readLine(): String {
		val str = input.readLine()
		return str
	}
	
	/**
	 * Reads all available data from the server.
	 *
	 * @return The data received (in a string)
	 * */
	@JvmName("read")
	internal fun read(): String {
		
		var text = input.readLine() // read the first line
		
		if (text.equals("{")) { // if we are dealing with a multi-line json string
			
			var command: String
			do {
				command = input.readLine()
				text += command + "\n"
			} while (command != "}") // read all the lines we have
			
			return text
			
		} else {
			return text // if its a normal string return the single line
		}
		
		/*		var text = ""
				do {
					val command = input.readLine();
					text += command + "\n"
				}while(command != null);
				
				return text.trim()*/
		
	}
	
	/**
	 * Writes data to the server.
	 *
	 * @param msg the string to send
	 * */
	@Deprecated("Been replaced", ReplaceWith("writeWholeLog"))
	internal fun writeLogLine(msg: String) {
		output.print(msg)
	}
	
	/**
	 * Writes data to the server.
	 *
	 * @param msg the turn log
	 * */
	internal fun writeWholeLog(msg: List<String>) {
		msg.forEach { output.println(it) }
		output.println("END")
	}
	
	/**
	 * Closes all server connections
	 * */
	internal fun close() {
		input.close()
		output.close()
		client.close()
	}
	
}
<commit_msg>gota love them socket exceptions<commit_after>package com.n9mtq4.botclient

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.net.ConnectException
import java.net.Socket
import java.net.SocketException

/**
 * Created by will on 11/27/15 at 11:16 PM.
 *
 * Handles all the client to server connections
 *
 * @author Will "n9Mtq4" Bresnahan
 */
class ServerConnection(val port: Int) {
	
	internal val client: Socket
	internal val input: BufferedReader
	internal val output: PrintWriter
	
	init {
		println("Connecting to server...")
		try {
			this.client = Socket("localhost", port)
			this.input = BufferedReader(InputStreamReader(client.inputStream))
			this.output = PrintWriter(client.outputStream, true)
			println("Successfully connected to server")
		}catch (e: ConnectException) {
			System.err.println("Is the server running?")
			e.printStackTrace()
			throw e
		}
	}
	
	/**
	 * Reads only one line from the server/
	 *
	 * @return a single line of data
	 * */
	internal fun readLine(): String {
		val str = input.readLine()
		return str
	}
	
	/**
	 * Reads all available data from the server.
	 *
	 * @return The data received (in a string)
	 * */
	@JvmName("read")
	internal fun read(): String {
		
		try {
			var text = input.readLine() // read the first line
			
			if (text.equals("{")) {
				// if we are dealing with a multi-line json string
				
				var command: String
				do {
					command = input.readLine()
					text += command + "\n"
				} while (command != "}") // read all the lines we have
				
				return text
				
			} else {
				return text // if its a normal string return the single line
			}
		}catch (e: SocketException) {
			System.err.println("Is the server running?")
			e.printStackTrace()
			throw e
		}
		/*		var text = ""
				do {
					val command = input.readLine();
					text += command + "\n"
				}while(command != null);
				
				return text.trim()*/
		
	}
	
	/**
	 * Writes data to the server.
	 *
	 * @param msg the string to send
	 * */
	@Deprecated("Been replaced", ReplaceWith("writeWholeLog"))
	internal fun writeLogLine(msg: String) {
		output.print(msg)
	}
	
	/**
	 * Writes data to the server.
	 *
	 * @param msg the turn log
	 * */
	internal fun writeWholeLog(msg: List<String>) {
		try {
			msg.forEach { output.println(it) }
			output.println("END")
		}catch (e: SocketException) {
			System.err.println("Is the server running?")
			e.printStackTrace()
			throw e
		}
	}
	
	/**
	 * Closes all server connections
	 * */
	internal fun close() {
		input.close()
		output.close()
		client.close()
	}
	
}

{'fraction_non_alphanumeric': 0.12365250475586556, 'fraction_numerical': 0.005918410484041429, 'mean_word_length': 2.8755118755118754, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6268795', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1466, 'n_words': 461}