File size: 2,028 Bytes
8a8fab3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
Minimal usage example for hv-tempo.

    python example.py

Runs the predictor on five contrasting texts and prints a comparison.
"""

from hv_tempo import HVTempo


TEXTS = {
    "fiction": (
        "The old man walked slowly to the boat. He stopped, looked at "
        "the water, and then continued. The sea was quiet that morning."
    ),
    "academic": (
        "A black hole is a region of spacetime where gravity is so "
        "strong that nothing - no particles or even electromagnetic "
        "radiation such as light - can escape from it."
    ),
    "technical": (
        "To install the package, first verify that your Python version "
        "is 3.9 or later. Then run the following command in your "
        "terminal. After installation, you may need to configure the "
        "API key."
    ),
    "list": (
        "The main contributions are: "
        "1. A new algorithm for feature extraction. "
        "2. A proof of the reconstruction floor. "
        "3. Empirical validation on four encoders."
    ),
    "mixed": (
        "Although the results are preliminary, they suggest that the "
        "method may generalize to other domains. However, the sample "
        "size is small, so the conclusions should be treated with "
        "caution. Further work is needed."
    ),
}


def main() -> None:
    m = HVTempo()

    print("=" * 72)
    print("hv-tempo comparison")
    print("=" * 72)
    print(f"  {'name':<12}  {'words':>6}  {'wpm':>6}  "
          f"{'duration':>9}  {'variance':>9}")
    print("  " + "-" * 62)
    for name, text in TEXTS.items():
        r = m.analyze(text)
        var = f"{r.pace_variance:.3f}" if r.pace_variance is not None else "n/a"
        print(f"  {name:<12}  {r.word_count:>6}  {r.mean_wpm:>6.0f}  "
              f"{r.total_duration_s:>8.2f}s  {var:>9}")

    print()
    print("=" * 72)
    print("Detailed profile: academic")
    print("=" * 72)
    r = m.analyze(TEXTS["academic"])
    print(m.render(r))


if __name__ == "__main__":
    main()