Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright 2013 Google Inc. All Rights Reserved. |
michael@0 | 2 | // |
michael@0 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 4 | // you may not use this file except in compliance with the License. |
michael@0 | 5 | // You may obtain a copy of the License at |
michael@0 | 6 | // |
michael@0 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 8 | // |
michael@0 | 9 | // Unless required by applicable law or agreed to in writing, software |
michael@0 | 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 12 | // See the License for the specific language governing permissions and |
michael@0 | 13 | // limitations under the License. |
michael@0 | 14 | |
michael@0 | 15 | // |
michael@0 | 16 | // Author: dsites@google.com (Dick Sites) |
michael@0 | 17 | // |
michael@0 | 18 | // Stuff used only by online detector, not used offline |
michael@0 | 19 | // |
michael@0 | 20 | |
michael@0 | 21 | #ifndef I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ |
michael@0 | 22 | #define I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ |
michael@0 | 23 | |
michael@0 | 24 | #include "cldutil_shared.h" |
michael@0 | 25 | #include "scoreonescriptspan.h" |
michael@0 | 26 | #include "tote.h" |
michael@0 | 27 | |
michael@0 | 28 | namespace CLD2 { |
michael@0 | 29 | |
michael@0 | 30 | // Score up to 64KB of a single script span in one pass |
michael@0 | 31 | // Make a dummy entry off the end to calc length of last span |
michael@0 | 32 | // Return offset of first unused input byte |
michael@0 | 33 | int GetUniHits(const char* text, |
michael@0 | 34 | int letter_offset, int letter_limit, |
michael@0 | 35 | ScoringContext* scoringcontext, |
michael@0 | 36 | ScoringHitBuffer* hitbuffer); |
michael@0 | 37 | |
michael@0 | 38 | // Score up to 64KB of a single script span, doing both delta-bi and |
michael@0 | 39 | // distinct bis in one pass |
michael@0 | 40 | void GetBiHits(const char* text, |
michael@0 | 41 | int letter_offset, int letter_limit, |
michael@0 | 42 | ScoringContext* scoringcontext, |
michael@0 | 43 | ScoringHitBuffer* hitbuffer); |
michael@0 | 44 | |
michael@0 | 45 | // Score up to 64KB of a single script span in one pass |
michael@0 | 46 | // Make a dummy entry off the end to calc length of last span |
michael@0 | 47 | // Return offset of first unused input byte |
michael@0 | 48 | int GetQuadHits(const char* text, |
michael@0 | 49 | int letter_offset, int letter_limit, |
michael@0 | 50 | ScoringContext* scoringcontext, |
michael@0 | 51 | ScoringHitBuffer* hitbuffer); |
michael@0 | 52 | |
michael@0 | 53 | // Score up to 64KB of a single script span, doing both delta-octa and |
michael@0 | 54 | // distinct words in one pass |
michael@0 | 55 | void GetOctaHits(const char* text, |
michael@0 | 56 | int letter_offset, int letter_limit, |
michael@0 | 57 | ScoringContext* scoringcontext, |
michael@0 | 58 | ScoringHitBuffer* hitbuffer); |
michael@0 | 59 | |
michael@0 | 60 | // Not sure if these belong here or in scoreonescriptspan.cc |
michael@0 | 61 | int ReliabilityDelta(int value1, int value2, int gramcount); |
michael@0 | 62 | int ReliabilityExpected(int actual_score_1kb, int expected_score_1kb); |
michael@0 | 63 | |
michael@0 | 64 | // Create a langprob packed value from its parts. |
michael@0 | 65 | uint32 MakeLangProb(Language lang, int qprob); |
michael@0 | 66 | |
michael@0 | 67 | |
michael@0 | 68 | void ProcessProbV2Tote(uint32 probs, Tote* tote); |
michael@0 | 69 | |
michael@0 | 70 | // Return score for a particular per-script language, or zero |
michael@0 | 71 | int GetLangScore(uint32 probs, uint8 pslang); |
michael@0 | 72 | |
michael@0 | 73 | static inline int minint(int a, int b) {return (a < b) ? a: b;} |
michael@0 | 74 | static inline int maxint(int a, int b) {return (a > b) ? a: b;} |
michael@0 | 75 | |
michael@0 | 76 | } // End namespace CLD2 |
michael@0 | 77 | |
michael@0 | 78 | #endif // I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ |
michael@0 | 79 | |
michael@0 | 80 |