<commit_before>package main

import (
	"bufio"
	"bytes"
	"encoding/json"
	"flag"
	"fmt"
	"log"
	"net"
	"net/http"
        "strings"
	"os"
)

// Instances of Msg store the transmited message and its source peer data 
type Msg struct {
	Message string
	From    Peer
}

// Peer stores screen name and ip address data
type Peer struct {
	Name    string
	Address string
}

// Peers provides a map of known Peers accessed by an Address
type Peers map[string]Peer

// PeerData implements the p2p control data for a peer
type PeerData struct {
	Self            Peer
	Peers           Peers
	addPeers        chan (Peer)
	exitPeer        chan (Peer)
	currentPeers    chan (Peers)
	getCurrentPeers chan (bool)
	receivedMsg     chan (Msg)
	userMsg         chan (Msg)
}

// Startup client logic
func main() {
        //Parse comandline argumments
	port := flag.String("p", "7500", "Port number")
	name := flag.String("n", "Surematics", "ScreenName")
	peer := flag.String("i", "", "IP address of peer to connect to.")
	flag.Parse()
        
        //initialize client control handler  
	peercontroller := NewPeerData(Peer{*name, getIp() + ":" + *port})
	peercontroller.start()
	
	if len(*peer) != 0 {
		peercontroller.addPeers <- Peer{"", *peer}
	}
        
        //scan stdin for input
	peercontroller.startStdinListener(peercontroller.Self)
}

// Get IP of this machine
func getIp() string {
    conn, err := net.Dial("udp", "8.8.8.8:80")
    if err != nil {
        return "localhost"
    }
    defer conn.Close()

    localAddr := conn.LocalAddr().String()
    idx := strings.LastIndex(localAddr, ":")<commit_msg>add tests<commit_after>package main

import (
	"bufio"
	"bytes"
	"encoding/json"
	"flag"
	"fmt"
	"log"
	"net"
	"net/http"
        "strings"
	"os"
)

// Instances of Msg store the transmited message and its source peer data 
type Msg struct {
	Message string
	From    Peer
}

// Peer stores screen name and ip address data
type Peer struct {
	Name    string
	Address string
}

// Peers provides a map of known Peers accessed by an Address
type Peers map[string]Peer

// PeerData implements the p2p control data for a peer
type PeerData struct {
	Self            Peer
	Peers           Peers
	addPeers        chan (Peer)
	exitPeer        chan (Peer)
	currentPeers    chan (Peers)
	getCurrentPeers chan (bool)
	receivedMsg     chan (Msg)
	userMsg         chan (Msg)
}

// Startup client logic
func main() {
        //Parse comandline argumments
	port := flag.String("p", "7500", "Port number")
	name := flag.String("n", "Surematics", "ScreenName")
	peer := flag.String("i", "", "IP address of peer to connect to.")
	flag.Parse()
        
        //initialize client control handler  
	peercontroller := NewPeerData(Peer{*name, GetIp() + ":" + *port})
	peercontroller.start()
	
	if len(*peer) != 0 {
		peercontroller.addPeers <- Peer{"", *peer}
	}
        
        //scan stdin for input
	peercontroller.startStdinListener(peercontroller.Self)
}

// Get IP of this machine
func GetIp() string {
    conn, err := net.Dial("udp", "8.8.8.8:80")
    if err != nil {
        return "localhost"
    }
    defer conn.Close()

    localAddr := conn.LocalAddr().String()
    idx := strings.LastIndex(localAddr, ":")
{'fraction_non_alphanumeric': 0.12164691203992514, 'fraction_numerical': 0.007485963817841547, 'mean_word_length': 2.7997630331753554, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3641002', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1045, 'n_words': 331}