summaryrefslogtreecommitdiffstats
path: root/browser/components/translation/cld2/cldapp.cc
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-06-04 13:17:38 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-04 13:17:38 +0200
commita1be17c1cea81ebb1e8b131a662c698d78f3f7f2 (patch)
treea92f7de513be600cc07bac458183e9af40e00c06 /browser/components/translation/cld2/cldapp.cc
parentbf11fdd304898ac675e39b01b280d39550e419d0 (diff)
downloadUXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.gz
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.lz
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.tar.xz
UXP-a1be17c1cea81ebb1e8b131a662c698d78f3f7f2.zip
Issue #303 Part 1: Move basilisk files from /browser to /application/basilisk
Diffstat (limited to 'browser/components/translation/cld2/cldapp.cc')
-rw-r--r--browser/components/translation/cld2/cldapp.cc107
1 files changed, 0 insertions, 107 deletions
diff --git a/browser/components/translation/cld2/cldapp.cc b/browser/components/translation/cld2/cldapp.cc
deleted file mode 100644
index 4750cc54b..000000000
--- a/browser/components/translation/cld2/cldapp.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "public/compact_lang_det.h"
-
-#define MAX_RESULTS 3
-
-class Language {
-public:
- Language(CLD2::Language lang) : mLang(lang) {}
-
- const char* getLanguageCode() const
- {
- return CLD2::LanguageCode(mLang);
- }
-
-private:
- const CLD2::Language mLang;
-};
-
-class LanguageGuess : public Language {
-public:
- LanguageGuess(CLD2::Language lang, char percent) :
- Language(lang), mPercent(percent) {}
-
- char getPercent() const
- {
- return mPercent;
- }
-
-private:
- const char mPercent;
-};
-
-
-class LanguageInfo : public Language {
-public:
- static LanguageInfo* detectLanguage(const char* buffer, bool isPlainText)
- {
- CLD2::Language languages[MAX_RESULTS] = {};
- int percentages[MAX_RESULTS] = {};
- bool isReliable = false;
-
- // This is ignored.
- int textBytes;
-
- CLD2::Language bestGuess = DetectLanguageSummary(
- buffer, strlen(buffer), isPlainText,
- languages, percentages, &textBytes,
- &isReliable);
-
- return new LanguageInfo(isReliable, bestGuess, languages, percentages);
- }
-
- static LanguageInfo* detectLanguage(const char* buffer, bool isPlainText,
- const char* tldHint, int encodingHint,
- const char* languageHint)
- {
- CLD2::CLDHints hints = {languageHint, tldHint, encodingHint, CLD2::UNKNOWN_LANGUAGE};
-
- CLD2::Language languages[MAX_RESULTS] = {};
- int percentages[MAX_RESULTS] = {};
- bool isReliable = false;
-
- // These are ignored.
- double scores[MAX_RESULTS];
- int textBytes;
-
- CLD2::Language bestGuess = ExtDetectLanguageSummary(
- buffer, strlen(buffer), isPlainText,
- &hints, 0,
- languages, percentages, scores,
- nullptr, &textBytes, &isReliable);
-
- return new LanguageInfo(isReliable, bestGuess, languages, percentages);
- }
-
- ~LanguageInfo()
- {
- for (int i = 0; i < MAX_RESULTS; i++) {
- delete languages[i];
- }
- }
-
- bool getIsReliable() const
- {
- return mIsReliable;
- }
-
- const LanguageGuess* languages[MAX_RESULTS];
-
-private:
- LanguageInfo(bool isReliable, CLD2::Language bestGuess,
- CLD2::Language languageIDs[MAX_RESULTS],
- int percentages[MAX_RESULTS]) :
- Language(bestGuess), mIsReliable(isReliable)
- {
- for (int i = 0; i < MAX_RESULTS; i++) {
- languages[i] = new LanguageGuess(languageIDs[i], percentages[i]);
- }
- }
-
- const bool mIsReliable;
-};
-
-#include "cld.cpp"