summaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/juniper/juniperparams.h
blob: 77422b026776e06a1aace8c38e142332e355bb1b (plain) (blame)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <string>
#include <vespa/fastlib/text/wordfolder.h>

class SummaryConfig;

class DocsumParams
{
public:
    enum {
        FALLBACK_NONE,
        FALLBACK_PREFIX
    };

    DocsumParams();

    DocsumParams& SetEnabled(bool en);
    bool Enabled() const;

    DocsumParams& SetLength(size_t length);
    size_t Length() const;

    DocsumParams& SetMinLength(size_t length);
    size_t MinLength() const;

    DocsumParams& SetMaxMatches(size_t matches);
    size_t MaxMatches() const;

    DocsumParams& SetSurroundMax(size_t length);
    size_t SurroundMax() const;

    DocsumParams& SetFallback(const char* fallback);
    int Fallback() const;

private:
    bool _enabled;
    size_t _length;
    size_t _min_length;
    size_t _max_matches;
    size_t _surround_max;
    int _fallback;
};


class MatcherParams
{
public:
    MatcherParams();
    MatcherParams(const MatcherParams&) = delete;
    MatcherParams(MatcherParams&&) = delete;
    MatcherParams &operator=(const MatcherParams&) = delete;
    MatcherParams &operator=(MatcherParams&&) = delete;

    MatcherParams& SetMatchWindowSize(size_t winsize);
    size_t MatchWindowSize() const;

    double MatchWindowSizeFallbackMultiplier() const;

    MatcherParams& SetMaxMatchCandidates(size_t max_match_candidates);
    size_t MaxMatchCandidates() const;

    MatcherParams& SetStemMinLength(size_t stem_min);
    size_t StemMinLength() const;

    MatcherParams& SetStemMaxExtend(size_t stem_extend);
    size_t StemMaxExtend() const;

    MatcherParams& SetWordFolder(const Fast_WordFolder* wordfolder);
    const Fast_WordFolder* WordFolder() const noexcept { return _wordfolder; }

    MatcherParams& SetProximityFactor(double factor);
    double ProximityFactor() const noexcept { return _proximity_factor; };

private:
    size_t _match_winsize;
    double _match_winsize_fallback_multiplier;
    size_t _max_match_candidates;
    size_t _stem_min;
    size_t _stem_extend;
    const Fast_WordFolder* _wordfolder; // The wordfolder object needed as 1st parameter to folderfun
    double _proximity_factor;
};


bool operator==(MatcherParams& mp1, MatcherParams& mp2);