aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/codecs/greedy_dict/gd_stats.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/codecs/greedy_dict/gd_stats.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/codecs/greedy_dict/gd_stats.h')
-rw-r--r--library/cpp/codecs/greedy_dict/gd_stats.h116
1 files changed, 58 insertions, 58 deletions
diff --git a/library/cpp/codecs/greedy_dict/gd_stats.h b/library/cpp/codecs/greedy_dict/gd_stats.h
index b63c4c38d2..90f46a0fb9 100644
--- a/library/cpp/codecs/greedy_dict/gd_stats.h
+++ b/library/cpp/codecs/greedy_dict/gd_stats.h
@@ -1,78 +1,78 @@
#pragma once
-#include <util/generic/ymath.h>
+#include <util/generic/ymath.h>
#include <util/generic/algorithm.h>
#include <util/generic/yexception.h>
namespace NGreedyDict {
- enum EEntryScore {
- ES_COUNT,
- ES_LEN_COUNT,
- ES_SIMPLE,
- ES_LEN_SIMPLE,
- ES_SOLAR
- };
+ enum EEntryScore {
+ ES_COUNT,
+ ES_LEN_COUNT,
+ ES_SIMPLE,
+ ES_LEN_SIMPLE,
+ ES_SOLAR
+ };
- enum EEntryStatTest {
- EST_NONE = 0,
- EST_SIMPLE_NORM = 2
- };
+ enum EEntryStatTest {
+ EST_NONE = 0,
+ EST_SIMPLE_NORM = 2
+ };
- inline float ModelP(ui32 countA, ui32 countB, ui32 total) {
- return float(countA) * countB / total / total;
- }
+ inline float ModelP(ui32 countA, ui32 countB, ui32 total) {
+ return float(countA) * countB / total / total;
+ }
- // P (ab | dependent)
- inline float SimpleTest(float modelp, ui32 countAB, ui32 total) {
- float realp = float(countAB) / total;
- return modelp >= realp ? 0 : (realp - modelp);
- }
+ // P (ab | dependent)
+ inline float SimpleTest(float modelp, ui32 countAB, ui32 total) {
+ float realp = float(countAB) / total;
+ return modelp >= realp ? 0 : (realp - modelp);
+ }
- inline float SolarTest(float modelp, ui32 countAB, ui32 total) {
- float realp = float(countAB) / total;
- return modelp >= realp ? 0 : (modelp + realp * (log(realp / modelp) - 1));
- }
+ inline float SolarTest(float modelp, ui32 countAB, ui32 total) {
+ float realp = float(countAB) / total;
+ return modelp >= realp ? 0 : (modelp + realp * (log(realp / modelp) - 1));
+ }
- // P (ab | dependent) / P (ab)
- inline float SimpleTestNorm(float modelp, ui32 countAB, ui32 total) {
- float realp = float(countAB) / total;
- return modelp >= realp ? 0 : (realp - modelp) / realp;
- }
+ // P (ab | dependent) / P (ab)
+ inline float SimpleTestNorm(float modelp, ui32 countAB, ui32 total) {
+ float realp = float(countAB) / total;
+ return modelp >= realp ? 0 : (realp - modelp) / realp;
+ }
- inline float StatTest(EEntryStatTest test, float modelp, ui32 countAB, ui32 total) {
- if (!total) {
- return 0;
- }
- switch (test) {
- case EST_NONE:
- return 1;
- case EST_SIMPLE_NORM:
- return SimpleTestNorm(modelp, countAB, total);
- }
- Y_FAIL("no way!");
+ inline float StatTest(EEntryStatTest test, float modelp, ui32 countAB, ui32 total) {
+ if (!total) {
+ return 0;
+ }
+ switch (test) {
+ case EST_NONE:
+ return 1;
+ case EST_SIMPLE_NORM:
+ return SimpleTestNorm(modelp, countAB, total);
+ }
+ Y_FAIL("no way!");
return 0;
}
- inline float Score(EEntryScore score, ui32 len, float modelp, ui32 count, ui32 total) {
- if (!total) {
- return 0;
- }
- ui32 m = 1;
- switch (score) {
- case ES_LEN_COUNT:
- m = len;
+ inline float Score(EEntryScore score, ui32 len, float modelp, ui32 count, ui32 total) {
+ if (!total) {
+ return 0;
+ }
+ ui32 m = 1;
+ switch (score) {
+ case ES_LEN_COUNT:
+ m = len;
[[fallthrough]];
- case ES_COUNT:
- return m * count;
- case ES_LEN_SIMPLE:
- m = len;
+ case ES_COUNT:
+ return m * count;
+ case ES_LEN_SIMPLE:
+ m = len;
[[fallthrough]];
- case ES_SIMPLE:
- return m * SimpleTest(modelp, count, total);
- case ES_SOLAR:
- return SolarTest(modelp, count, total);
- }
- Y_FAIL("no way!");
+ case ES_SIMPLE:
+ return m * SimpleTest(modelp, count, total);
+ case ES_SOLAR:
+ return SolarTest(modelp, count, total);
+ }
+ Y_FAIL("no way!");
return 0;
}