Debian Codegraph @

src/rime/gear/poet.h

raw symbols SCIP
1 //cxx . . $ `<file>/src/rime/gear/poet.h`/
2 // Copyright RIME Developers
3 // Distributed under the BSD License
4 //
5 // simplistic sentence-making
6 //
7 // 2011-10-06 GONG Chen <[email protected]>
8 //
9
10 #ifndef RIME_POET_H_
11 #define RIME_POET_H_cxx . . $ `src/rime/gear/poet.h:11:9`!
12
13 #include <rime/common.h>cxx . . $ `<file>/src/rime/common.h`/
14 #include <rime/translation.h>cxx . . $ `<file>/src/rime/translation.h`/
15 #include <rime/gear/translator_commons.h>cxx . . $ `<file>/src/rime/gear/translator_commons.h`/
16 #include <rime/gear/contextual_translation.h>cxx . . $ `<file>/src/rime/gear/contextual_translation.h`/
17
18 namespace rimecxx . . $ rime/ {
19
20 using WordGraphcxx . . $ rime/WordGraph# = mapcxx . . $ rime/map#<int, mapcxx . . $ rime/map#<int, DictEntryListcxx . . $ rime/DictEntryList#>>;
21
22 class Grammarcxx . . $ rime/Grammar#;
23 class Languagecxx . . $ rime/Language#;
24 struct Linecxx . . $ rime/Line#;
25
26 class Poetcxx . . $ rime/Poet# {
27 public:
28 // Line "less", used to compare composed line of the same input range.
29 using Comparecxx . . $ rime/Poet#Compare# = functioncxx . . $ rime/function#<bool(const Linecxx . . $ rime/Line#&, const Linecxx . . $ rime/Line#&)>;
30
31 static bool CompareWeightcxx . . $ rime/Poet#CompareWeight(f8f1d6e84d541087).(const Linecxx . . $ rime/Line#& one, const Linecxx . . $ rime/Line#& other);
32 static bool LeftAssociateComparecxx . . $ rime/Poet#LeftAssociateCompare(f8f1d6e84d541087).(const Linecxx . . $ rime/Line#& one, const Linecxx . . $ rime/Line#& other);
33
34 Poetcxx . . $ rime/Poet#Poet(f9de4a1195fa4c43).(const Languagecxx . . $ rime/Language#* language,
35 Configcxx . . $ rime/Config#* config,
36 Comparecxx . . $ rime/Poet#Compare# compare = CompareWeightcxx . . $ std/function#function(bdc3712e480e4d04).);
37 ~cxx . . $ rime/Poet#`~Poet`(ced63f7c635d850d).Poetcxx . . $ rime/Poet#();
38
39 ancxx . . $ rime/an#<Sentencecxx . . $ rime/Sentence#> MakeSentencecxx . . $ rime/Poet#MakeSentence(5a27e0d98eaae4ac).(const WordGraphcxx . . $ rime/WordGraph#& graph,
40 size_t total_length,
41 const stringcxx . . $ rime/string#& preceding_text);
42 dequecxx . . $ rime/deque#<ancxx . . $ rime/an#<Sentencecxx . . $ rime/Sentence#>> MakeSentencescxx . . $ rime/Poet#MakeSentences(45870f1970b92604).(const WordGraphcxx . . $ rime/WordGraph#& graph,
43 size_t total_length,
44 const stringcxx . . $ rime/string#& preceding_text,
45 size_t count,
46 double cutoff_threshold);
47
48 template <class TranslatorT>
49 ancxx . . $ rime/an#<Translationcxx . . $ rime/Translation#> ContextualWeightedcxx . . $ rime/Poet#ContextualWeighted(ab4a42b9da5e2c8c).(ancxx . . $ rime/an#<Translationcxx . . $ rime/Translation#> translation,
50 const stringcxx . . $ rime/string#& input,
51 size_t start,
52 TranslatorT* translator) {
53 if (!translator->contextual_suggestions() || !grammar_cxx . . $ rime/Poet#grammar_.) {
54 return translationcxx . . $ std/shared_ptr#shared_ptr(e98954a1f10335bf).;
55 }
56 auto preceding_text = translator->GetPrecedingText(start);
57 if (preceding_text.empty()) {
58 return translationcxx . . $ std/shared_ptr#shared_ptr(e98954a1f10335bf).;
59 }
60 return Newcxx . . $ rime/New(25752750ef11e821).<ContextualTranslationcxx . . $ rime/ContextualTranslation#>(translation, input, preceding_text,
61 grammar_cxx . . $ rime/Poet#grammar_..getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).());
62 }
63
64 private:
65 template <class Strategy>
66 ancxx . . $ rime/an#<Sentencecxx . . $ rime/Sentence#> MakeSentenceWithStrategycxx . . $ rime/Poet#MakeSentenceWithStrategy(5a27e0d98eaae4ac).(const WordGraphcxx . . $ rime/WordGraph#& graph,
67 size_t total_length,
68 const stringcxx . . $ rime/string#& preceding_text);
69
70 const Languagecxx . . $ rime/Language#* language_cxx . . $ rime/Poet#language_.;
71 thecxx . . $ rime/the#<Grammarcxx . . $ rime/Grammar#> grammar_cxx . . $ rime/Poet#grammar_.;
72 Comparecxx . . $ rime/Poet#Compare# compare_cxx . . $ rime/Poet#compare_.;
73 };
74
75 } // namespace rime
76
77 #endif // RIME_POET_H_