<commit_before>package main

import (
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
)

const DDG_URL = "http://api.duckduckgo.com/"

func QueryDDG(query string) (*DDGResponse, error) {
	queryURL := addArgToURL(DDG_URL, "q", query)
	queryURL = addArgToURL(queryURL, "format", "json")
	resp, err := http.Get(queryURL)

	if err != nil {
		return nil, err
	}

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		return nil, err
	}

	return NewDDGResponse(body)
}

func addArgToURL(baseURL string, key string, value string) string {
	u, err := url.Parse(baseURL)

	if err != nil {
		log.Fatal(err)
		return ""
	}

	q := u.Query()<commit_msg>all queries are now lowercased since DuckDuckGo is case sensitive, and texting rarely is<commit_after>package main

import (
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"strings"
)

const DDG_URL = "http://api.duckduckgo.com/"

func QueryDDG(query string) (*DDGResponse, error) {
	// DuckDuckGo is case sensitive, which is annoying for text messaging
	query = strings.ToLower(query)

	queryURL := addArgToURL(DDG_URL, "q", query)
	queryURL = addArgToURL(queryURL, "format", "json")
	resp, err := http.Get(queryURL)

	if err != nil {
		return nil, err
	}

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		return nil, err
	}

	return NewDDGResponse(body)
}

func addArgToURL(baseURL string, key string, value string) string {
	u, err := url.Parse(baseURL)

	if err != nil {
		log.Fatal(err)
		return ""
	}

	q := u.Query()
{'fraction_non_alphanumeric': 0.14323258869908015, 'fraction_numerical': 0.0, 'mean_word_length': 3.9448051948051948, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5569718', 'n_tokens_mistral': 618, 'n_tokens_neox': 589, 'n_words': 151}