<commit_before>import Vapor
import Foundation

struct Country {
    let name: String
    let code: String
    let police: Int
    let medical: Int
    let fire: Int
}

extension Country: JsonRepresentable {
    
    func makeJson() -> Json {
        return Json(["name": name,
                     "code": code,
                     "police": police,
                     "medical": medical,
                     "fire": fire])
    }
}

class DataSource: JsonRepresentable {
    
    
    func makeJson() -> Json {
        let content = DataSource().source.map { $0.makeJson() }
        return Json.object(["version" : Json(APIVersion), "content": Json.array(content)])
    }
    
    func getCountryWithID(countryCode: String) -> Json {
        let country = source.filter { $0.code == countryCode }
        guard let result = country.first else {
            return Json(["error": "No country found with the given 2-digit country code \(countryCode)"])
        }
        return result.makeJson()
    }

    let APIVersion = 0.1

    let source = [Country(name: "Afghanistan", code: "AF", police: 120, medical: 0, fire: 119).self,
                  Country(name: "Albania", code: "AL", police: 0, medical: 0, fire: 128).self,
                  Country(name: "Algeria", code: "DZ", police: 0, medical: 0, fire: 14).self,
                  Country(name: "Argentina", code: "AR", police: 0, medical: 0, fire: 100).self,
                  Country(name: "Armenia", code: "AM", police: 0, medical: 0, fire: 101).self,
                  Country(name: "Austria", code: "AT", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Australia", code: "AU", police: 0, medical: 0, fire: 000).self,
                  Country(name: "Bahrain", code: "BH", police: 0, medical: 0, fire: 999).self,
                  Country(name: "Bangladesh", code: "BD", police: 0, medical: 0, fire: 102).self,
                  Country(name: "Barbados", code: "BB", police: 0, medical: 0, fire: 911).self,
                  Country(name: "Belarus", code: "BY", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Belgium", code: "BE", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Bolivia", code: "BO", police: 0, medical: 0, fire: 119).self,
                  Country(name: "Bosnia and Herzegovina", code: "BA", police: 0, medical: 0, fire: 123).self,
                  Country(name: "Botswana", code: "BW", police: 0, medical: 0, fire: 998).self,
                  Country(name: "Brazil", code: "BR", police: 0, medical: 0, fire: 103).self,
                  Country(name: "Brunei", code: "BN", police: 0, medical: 0, fire: 995).self,
                  Country(name: "Bulgaria", code: "BG", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Canada", code: "CA", police: 0, medical: 0, fire: 911).self,
                  Country(name: "Cayman Islands", code: "KY", police: 0, medical: 0, fire: 911).self,
                  Country(name: "Chad", code: "TD", police: 0, medical: 0, fire: 18).self,<commit_msg>Fixed typo<commit_after>import Vapor
import Foundation

struct Country {
    let name: String
    let code: String
    let police: Int
    let medical: Int
    let fire: Int
}

extension Country: JsonRepresentable {
    
    func makeJson() -> Json {
        return Json(["name": name,
                     "code": code,
                     "police": police,
                     "medical": medical,
                     "fire": fire])
    }
}

class DataSource: JsonRepresentable {
    
    
    func makeJson() -> Json {
        let content = DataSource().source.map { $0.makeJson() }
        return Json.object(["version" : Json(APIVersion), "content": Json.array(content)])
    }
    
    func getCountryWithID(countryCode: String) -> Json {
        let country = source.filter { $0.code == countryCode }
        guard let result = country.first else {
            return Json(["error": "No country found with the given 2-letter country code \(countryCode)"])
        }
        return result.makeJson()
    }

    let APIVersion = 0.1

    let source = [Country(name: "Afghanistan", code: "AF", police: 0, medical: 102, fire: 119).self,
                  Country(name: "Albania", code: "AL", police: 0, medical: 0, fire: 128).self,
                  Country(name: "Algeria", code: "DZ", police: 0, medical: 0, fire: 14).self,
                  Country(name: "Argentina", code: "AR", police: 0, medical: 0, fire: 100).self,
                  Country(name: "Armenia", code: "AM", police: 0, medical: 0, fire: 101).self,
                  Country(name: "Austria", code: "AT", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Australia", code: "AU", police: 0, medical: 0, fire: 000).self,
                  Country(name: "Bahrain", code: "BH", police: 0, medical: 0, fire: 999).self,
                  Country(name: "Bangladesh", code: "BD", police: 0, medical: 0, fire: 102).self,
                  Country(name: "Barbados", code: "BB", police: 0, medical: 0, fire: 911).self,
                  Country(name: "Belarus", code: "BY", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Belgium", code: "BE", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Bolivia", code: "BO", police: 0, medical: 0, fire: 119).self,
                  Country(name: "Bosnia and Herzegovina", code: "BA", police: 0, medical: 0, fire: 123).self,
                  Country(name: "Botswana", code: "BW", police: 0, medical: 0, fire: 998).self,
                  Country(name: "Brazil", code: "BR", police: 0, medical: 0, fire: 103).self,
                  Country(name: "Brunei", code: "BN", police: 0, medical: 0, fire: 995).self,
                  Country(name: "Bulgaria", code: "BG", police: 0, medical: 0, fire: 112).self,
                  Country(name: "Canada", code: "CA", police: 0, medical: 0, fire: 911).self,
                  Country(name: "Cayman Islands", code: "KY", police: 0, medical: 0, fire: 911).self,
                  Country(name: "Chad", code: "TD", police: 0, medical: 0, fire: 18).self,
{'fraction_non_alphanumeric': 0.15459882583170254, 'fraction_numerical': 0.03587736464448793, 'mean_word_length': 2.2245005257623554, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 9, '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': '1735668', 'n_tokens_mistral': 2120, 'n_tokens_neox': 1832, 'n_words': 598}