<commit_before>package com.chrhsmt.sisheng.point

import de.qaware.chronix.distance.DistanceFunctionEnum
import de.qaware.chronix.distance.DistanceFunctionFactory
import de.qaware.chronix.dtw.FastDTW
import de.qaware.chronix.dtw.TimeWarpInfo
import de.qaware.chronix.timeseries.MultivariateTimeSeries

/**
 * Created by chihiro on 2017/10/10.
 */
open class SimplePointCalculator : PointCalculator() {

    override fun calc(frequencies: MutableList<Float>, testFrequencies: MutableList<Float>): Point {

        var analyzedFreqList: MutableList<Float> = this.copy(frequencies)
        this.adjustFrequencies(analyzedFreqList)

        analyzedFreqList = this.removeLastSilence(analyzedFreqList)
        this.minimizeSilence(analyzedFreqList)
        val exampleFrequencies = this.removeLastSilence(testFrequencies)

        val info: TimeWarpInfo = this.calcDistance(analyzedFreqList, exampleFrequencies)

        val score = this.getScore(info.normalizedDistance)
        return Point(
                score,
                info.distance,
                info.normalizedDistance,
                this.getBase(info))

//        var items = this.frequencies.mapIndexed { index, fl -> TimeSeriesItem(index.toDouble(), TimeSeriesPoint(kotlin.DoubleArray(1){ fl.toDouble() })) }
//        val ts0 = TimeSeriesBase(items)
//
//        items = testFrequencies.mapIndexed { index, fl -> TimeSeriesItem(index.toDouble(), TimeSeriesPoint(kotlin.DoubleArray(1){ fl.toDouble() })) }
//        val ts1 = TimeSeriesBase(items)
//        return FastDTW.compare(ts0, ts1, Distances.EUCLIDEAN_DISTANCE)
//    }
    }

    open fun getScore(nomalizedDistance: Double): Int {
        return 100 - Math.max(nomalizedDistance.toInt() - 10, 0)
    }

    private fun getBase(info: TimeWarpInfo) : Int {
        val field = TimeWarpInfo::class.java.getDeclaredField("base")
        field.isAccessible = true
        return field.getInt(info)
    }
}<commit_msg>Fix problem of negative point calculation<commit_after>package com.chrhsmt.sisheng.point

import de.qaware.chronix.distance.DistanceFunctionEnum
import de.qaware.chronix.distance.DistanceFunctionFactory
import de.qaware.chronix.dtw.FastDTW
import de.qaware.chronix.dtw.TimeWarpInfo
import de.qaware.chronix.timeseries.MultivariateTimeSeries

/**
 * Created by chihiro on 2017/10/10.
 */
open class SimplePointCalculator : PointCalculator() {

    override fun calc(frequencies: MutableList<Float>, testFrequencies: MutableList<Float>): Point {

        var analyzedFreqList: MutableList<Float> = this.copy(frequencies)
        this.adjustFrequencies(analyzedFreqList)

        analyzedFreqList = this.removeLastSilence(analyzedFreqList)
        this.minimizeSilence(analyzedFreqList)
        val exampleFrequencies = this.removeLastSilence(testFrequencies)

        val info: TimeWarpInfo = this.calcDistance(analyzedFreqList, exampleFrequencies)

        val score = this.getScore(info.normalizedDistance)
        return Point(
                score,
                info.distance,
                info.normalizedDistance,
                this.getBase(info))

//        var items = this.frequencies.mapIndexed { index, fl -> TimeSeriesItem(index.toDouble(), TimeSeriesPoint(kotlin.DoubleArray(1){ fl.toDouble() })) }
//        val ts0 = TimeSeriesBase(items)
//
//        items = testFrequencies.mapIndexed { index, fl -> TimeSeriesItem(index.toDouble(), TimeSeriesPoint(kotlin.DoubleArray(1){ fl.toDouble() })) }
//        val ts1 = TimeSeriesBase(items)
//        return FastDTW.compare(ts0, ts1, Distances.EUCLIDEAN_DISTANCE)
//    }
    }

    open fun getScore(nomalizedDistance: Double): Int {
        return Math.max(100 - Math.max(nomalizedDistance.toInt() - 10, 0), 0)
    }

    private fun getBase(info: TimeWarpInfo) : Int {
        val field = TimeWarpInfo::class.java.getDeclaredField("base")
        field.isAccessible = true
        return field.getInt(info)
    }
}
{'fraction_non_alphanumeric': 0.10445859872611465, 'fraction_numerical': 0.010445859872611466, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6346637', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1196, 'n_words': 206}