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>
23#include <vector>
24#include "guess.hxx"
25
26#define MAX_STRING_LENGTH_TO_ANALYSE 200
27
28class SimpleGuesser final
29{
30public:
33
38
43
49 std::vector<Guess> GuessLanguage(const char* text);
50
56 Guess GuessPrimaryLanguage(const char* text);
57
62 std::vector<Guess> GetAvailableLanguages();
63
68 std::vector<Guess> GetAllManagedLanguages();
69
74 std::vector<Guess> GetUnavailableLanguages();
75
80 void EnableLanguage(const std::string& lang);
81
86 void DisableLanguage(const std::string& lang);
87
93 void SetDBPath(const char* thePathOfConfFile, const char* prefix);
94
95private:
96 //Where typical fingerprints (n-gram tables) are stored
97 void* h;
98
99 //Is used to select languages into the fingerprints DB, the mask is used to indicate if we want enabled disabled or both
100 std::vector<Guess> GetManagedLanguages(const char mask);
101
102 //Like getManagedLanguages, this function enable or disable a language and it depends of the mask
103 void XableLanguage(const std::string& lang, char mask);
104};
105
106#endif
107
108/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: guess.hxx:31
std::vector< Guess > GetManagedLanguages(const char mask)
Is used to know which language is available, unavailable or both when mask = 0xF0,...
std::vector< Guess > GetAllManagedLanguages()
List all languages (possibly in guesses or not)
SimpleGuesser()
inits the object with conf file "./conf.txt"
void XableLanguage(const std::string &lang, char mask)
void DisableLanguage(const std::string &lang)
Mark a language disabled.
void SetDBPath(const char *thePathOfConfFile, const char *prefix)
Load a new DB of fingerprints.
~SimpleGuesser()
destroy the object
SimpleGuesser & operator=(const SimpleGuesser &sg)
Guess GuessPrimaryLanguage(const char *text)
Analyze a text and return the most probable language of the text.
std::vector< Guess > GetAvailableLanguages()
List all available languages (possibly to be in guesses)
std::vector< Guess > GuessLanguage(const char *text)
Analyze a text and return the most probable languages of the text.
std::vector< Guess > GetUnavailableLanguages()
List all Unavailable languages (disable for any reason)
void EnableLanguage(const std::string &lang)
Mark a language enabled.
def text(shape, orig_st)