<commit_before>package totoro.yui.util.api

import com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.result.Result
import totoro.yui.util.api.data.Weather

object Wttr {
    private val escapeCodesRegex = "\u001B\\[[;\\d]*m".toRegex()

    fun get(location: String, success: (Weather) -> Unit, failure: () -> Unit) {
        "http://wttr.in/$location".httpGet().header("User-Agent" to "curl/7.58.0").responseString { _, _, result ->
            when (result) {
                is Result.Failure -> failure()
                is Result.Success -> {
                    val lines = result.value.split('\n').take(7).map { it.replace(escapeCodesRegex, "") }
                    if (lines[0].startsWith("ERROR")) failure()
                    else {
                        val loc = lines[0].split(':')[1].trim()
                        val condition = lines[2].drop(15).trim()
                        val temperature = lines[3].drop(15).trim()
                        val wind = lines[4].drop(15).trim()
                        val visibility = lines[5].drop(15).trim()
                        val precipitation = lines[6].drop(15).trim()
                        success(Weather(loc, condition, temperature, wind, visibility, precipitation))
                    }
                }
            }
        }
    }
}<commit_msg>convert the wind speed in weather data to m/s<commit_after>package totoro.yui.util.api

import com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.result.Result
import totoro.yui.util.api.data.Weather

object Wttr {
    private val escapeCodesRegex = "\u001B\\[[;\\d]*m".toRegex()

    fun get(location: String, success: (Weather) -> Unit, failure: () -> Unit) {
        "http://wttr.in/$location".httpGet().header("User-Agent" to "curl/7.58.0").responseString { _, _, result ->
            when (result) {
                is Result.Failure -> failure()
                is Result.Success -> {
                    val lines = result.value.split('\n').take(7).map { it.replace(escapeCodesRegex, "") }
                    if (lines[0].startsWith("ERROR")) failure()
                    else {
                        val loc = lines[0].split(':')[1].trim()
                        val condition = lines[2].drop(15).trim()
                        val temperature = lines[3].drop(15).trim()
                        val windKmH = lines[4].drop(15).trim()
                        val windMSec = windKmH.take(2) +
                                (Math.round((windKmH.drop(2).dropLast(5).toIntOrNull()?.times(0.277778) ?: -1.0) * 100.0) / 100.0).toString() + " m/s"
                        val visibility = lines[5].drop(15).trim()
                        val precipitation = lines[6].drop(15).trim()
                        success(Weather(loc, condition, temperature, windMSec, visibility, precipitation))
                    }
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.15036045314109167, 'fraction_numerical': 0.024716786817713696, 'mean_word_length': 1.63710407239819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '664062', 'n_tokens_mistral': 879, 'n_tokens_neox': 822, 'n_words': 146}