LibreOffice Module lingucomponent (master)  1
simpleguesser.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_LINGUCOMPONENT_SOURCE_LANGUAGEGUESSING_SIMPLEGUESSER_HXX
20 #define INCLUDED_LINGUCOMPONENT_SOURCE_LANGUAGEGUESSING_SIMPLEGUESSER_HXX
21 
22 #include <string.h>
23 #include <string>
24 #include <cstdlib>
25 #include <vector>
26 #include "guess.hxx"
27 
28 #define MAX_STRING_LENGTH_TO_ANALYSE 200
29 
30 using namespace std;
31 
32 class SimpleGuesser final {
33 public:
35  SimpleGuesser();
36 
40  SimpleGuesser& operator=(const SimpleGuesser& sg);
41 
45  ~SimpleGuesser();
46 
52  vector<Guess> GuessLanguage(const char* text);
53 
59  Guess GuessPrimaryLanguage(const char* text);
60 
65  vector<Guess> GetAvailableLanguages();
66 
71  vector<Guess> GetAllManagedLanguages();
72 
77  vector<Guess> GetUnavailableLanguages();
78 
83  void EnableLanguage(const string& lang);
84 
89  void DisableLanguage(const string& lang);
90 
96  void SetDBPath(const char* thePathOfConfFile, const char* prefix);
97 
98 private:
99 
100  //Where typical fingerprints (n-gram tables) are stored
101  void* h;
102 
103  //Is used to select languages into the fingerprints DB, the mask is used to indicate if we want enabled disabled or both
104  vector<Guess> GetManagedLanguages(const char mask);
105 
106  //Like getManagedLanguages, this function enable or disable a language and it depends of the mask
107  void XableLanguage(const string& lang, char mask);
108 };
109 
110 #endif
111 
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: guess.hxx:33
def text(shape, st)