<commit_before>package searcher

import (
	"encoding/json"
	"io"
	"net/http"
	"net/url"
)

// DoHTTPGet performs a HTTP get request
func DoHTTPGet(url string) (io.ReadCloser, error) {
	response, err := http.Get(url)

	if err != nil {
		return nil, err
	}

	return response.Body, nil
}

// URLEncodeString  encodes a string as URL-safe
func URLEncodeString(str string) (string, error) {
	encoded, err := url.Parse(str)

	if err != nil {
		return "", err
	}

	return encoded.String(), nil
}

// FormatSearchToURL appends a question to a SO API url
func FormatSearchToURL(question string) (output string) {
	formatted, _ := URLEncodeString(question)

	return "https://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&accepted=True&site=stackoverflow&q=" + formatted
}

// SearchByQuery does a GET request to the StackOverflow API, returning it's body
func SearchByQuery(query string) (io.ReadCloser, error) {
	url := FormatSearchToURL(query)

	response, err := DoHTTPGet(url)

	return response, err
}

// GetStackOverflowQuestions Fetches a list of questions from stackoverflow matching a query
func GetStackOverflowQuestions(question string) ([]Question, error) {
	body, err := SearchByQuery(question)

	if err != nil {
		return nil, err
	}

	var questions = new(Questions)

	err = json.NewDecoder(body).Decode(questions)
	body.Close()

	if err != nil {
		return nil, err
	}

	return questions.Items, nil
}

// GetStackOverflowAnswers returns an array of answers of questions
func GetStackOverflowAnswers(questions []Question) error {
	return nil
}
<commit_msg>Add function for generating a semicolon-seperated string of question ids<commit_after>package searcher

import (
	"encoding/json"
	"io"
	"net/http"
	"net/url"
	"strconv"
	"strings"
)

// DoHTTPGet performs a HTTP get request
func DoHTTPGet(url string) (io.ReadCloser, error) {
	response, err := http.Get(url)

	if err != nil {
		return nil, err
	}

	return response.Body, nil
}

// QuestionsIDToColonSeparateString creates a semicolon-separated string of IDs
func QuestionsIDToColonSeparateString(questions []Question) string {
	if len(questions) == 0 {
		return ""
	}

	var output string

	for _, question := range questions {
		output += strconv.Itoa(question.QuestionID) + ";"
	}

	// Remove the last semicolon from output
	var trimmed = strings.TrimSuffix(output, ";")

	return trimmed
}

// FormatAnswersURL gets an url that fetches an array of answers for questions
func FormatAnswersURL(questions []Question) string {
	return ""
}

// URLEncodeString  encodes a string as URL-safe
func URLEncodeString(str string) (string, error) {
	encoded, err := url.Parse(str)

	if err != nil {
		return "", err
	}

	return encoded.String(), nil
}

// FormatSearchToURL appends a question to a SO API url
func FormatSearchToURL(question string) (output string) {
	formatted, _ := URLEncodeString(question)

	return "https://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&accepted=True&site=stackoverflow&q=" + formatted
}

// SearchByQuery does a GET request to the StackOverflow API, returning it's body
func SearchByQuery(query string) (io.ReadCloser, error) {
	url := FormatSearchToURL(query)

	response, err := DoHTTPGet(url)

	return response, err
}

// GetStackOverflowQuestions Fetches a list of questions from stackoverflow matching a query
func GetStackOverflowQuestions(question string) ([]Question, error) {
	body, err := SearchByQuery(question)

	if err != nil {
		return nil, err
	}

	var questions = new(Questions)

	err = json.NewDecoder(body).Decode(questions)
	body.Close()

	if err != nil {
		return nil, err
	}

	return questions.Items, nil
}

// GetStackOverflowAnswers returns an array of answers of questions
func GetStackOverflowAnswers(questions []Question) error {
	return nil
}

{'fraction_non_alphanumeric': 0.10560969186199631, 'fraction_numerical': 0.001316829075585989, 'mean_word_length': 4.577092511013216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6052060', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1197, 'n_words': 363}