Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / lingucomponent / source / languageguessing / simpleguesser.hxx
blob34abf26d4fcfe98c3a50682673af81476ab1a597
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_LINGUCOMPONENT_SOURCE_LANGUAGEGUESSING_SIMPLEGUESSER_HXX
20 #define INCLUDED_LINGUCOMPONENT_SOURCE_LANGUAGEGUESSING_SIMPLEGUESSER_HXX
22 #include <string.h>
23 #include <string>
24 #include <cstdlib>
25 #include <vector>
26 #include "guess.hxx"
28 #define MAX_STRING_LENGTH_TO_ANALYSE 200
30 using namespace std;
32 class SimpleGuesser final {
33 public:
34 /**inits the object with conf file "./conf.txt"*/
35 SimpleGuesser();
37 /**
38 * @param SimpleGuesser& sg the other guesser
40 SimpleGuesser& operator=(const SimpleGuesser& sg);
42 /**
43 * destroy the object
45 ~SimpleGuesser();
47 /**
48 * Analyze a text and return the most probable languages of the text
49 * @param char* text is the text to analyze
50 * @return the list of guess
52 vector<Guess> GuessLanguage(const char* text);
54 /**
55 * Analyze a text and return the most probable language of the text
56 * @param char* text is the text to analyze
57 * @return the guess (containing language)
59 Guess GuessPrimaryLanguage(const char* text);
61 /**
62 * List all available languages (possibly to be in guesses)
63 * @return the list of languages
65 vector<Guess> GetAvailableLanguages();
67 /**
68 * List all languages (possibly in guesses or not)
69 * @return the list of languages
71 vector<Guess> GetAllManagedLanguages();
73 /**
74 * List all Unavailable languages (disable for any reason)
75 * @return the list of languages
77 vector<Guess> GetUnavailableLanguages();
79 /**
80 * Mark a language enabled
81 * @param string lang the language to enable (build like language-COUNTRY-encoding)
83 void EnableLanguage(const string& lang);
85 /**
86 * Mark a language disabled
87 * @param string lang the language to disable (build like language-COUNTRY-encoding)
89 void DisableLanguage(const string& lang);
91 /**
92 * Load a new DB of fingerprints
93 * @param const char* thePathOfConfFile self explaining
94 * @param const char* prefix is the path where the directory which contains fingerprint files is stored
96 void SetDBPath(const char* thePathOfConfFile, const char* prefix);
98 private:
100 //Where typical fingerprints (n-gram tables) are stored
101 void* h;
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);
106 //Like getManagedLanguages, this function enable or disable a language and it depends of the mask
107 void XableLanguage(const string& lang, char mask);
110 #endif
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */