1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/translation/cld2/internal/cldutil.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 1.4 +// Copyright 2013 Google Inc. All Rights Reserved. 1.5 +// 1.6 +// Licensed under the Apache License, Version 2.0 (the "License"); 1.7 +// you may not use this file except in compliance with the License. 1.8 +// You may obtain a copy of the License at 1.9 +// 1.10 +// http://www.apache.org/licenses/LICENSE-2.0 1.11 +// 1.12 +// Unless required by applicable law or agreed to in writing, software 1.13 +// distributed under the License is distributed on an "AS IS" BASIS, 1.14 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.15 +// See the License for the specific language governing permissions and 1.16 +// limitations under the License. 1.17 + 1.18 +// 1.19 +// Author: dsites@google.com (Dick Sites) 1.20 +// 1.21 +// Stuff used only by online detector, not used offline 1.22 +// 1.23 + 1.24 +#ifndef I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ 1.25 +#define I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ 1.26 + 1.27 +#include "cldutil_shared.h" 1.28 +#include "scoreonescriptspan.h" 1.29 +#include "tote.h" 1.30 + 1.31 +namespace CLD2 { 1.32 + 1.33 +// Score up to 64KB of a single script span in one pass 1.34 +// Make a dummy entry off the end to calc length of last span 1.35 +// Return offset of first unused input byte 1.36 +int GetUniHits(const char* text, 1.37 + int letter_offset, int letter_limit, 1.38 + ScoringContext* scoringcontext, 1.39 + ScoringHitBuffer* hitbuffer); 1.40 + 1.41 +// Score up to 64KB of a single script span, doing both delta-bi and 1.42 +// distinct bis in one pass 1.43 +void GetBiHits(const char* text, 1.44 + int letter_offset, int letter_limit, 1.45 + ScoringContext* scoringcontext, 1.46 + ScoringHitBuffer* hitbuffer); 1.47 + 1.48 +// Score up to 64KB of a single script span in one pass 1.49 +// Make a dummy entry off the end to calc length of last span 1.50 +// Return offset of first unused input byte 1.51 +int GetQuadHits(const char* text, 1.52 + int letter_offset, int letter_limit, 1.53 + ScoringContext* scoringcontext, 1.54 + ScoringHitBuffer* hitbuffer); 1.55 + 1.56 +// Score up to 64KB of a single script span, doing both delta-octa and 1.57 +// distinct words in one pass 1.58 +void GetOctaHits(const char* text, 1.59 + int letter_offset, int letter_limit, 1.60 + ScoringContext* scoringcontext, 1.61 + ScoringHitBuffer* hitbuffer); 1.62 + 1.63 +// Not sure if these belong here or in scoreonescriptspan.cc 1.64 +int ReliabilityDelta(int value1, int value2, int gramcount); 1.65 +int ReliabilityExpected(int actual_score_1kb, int expected_score_1kb); 1.66 + 1.67 +// Create a langprob packed value from its parts. 1.68 +uint32 MakeLangProb(Language lang, int qprob); 1.69 + 1.70 + 1.71 +void ProcessProbV2Tote(uint32 probs, Tote* tote); 1.72 + 1.73 +// Return score for a particular per-script language, or zero 1.74 +int GetLangScore(uint32 probs, uint8 pslang); 1.75 + 1.76 +static inline int minint(int a, int b) {return (a < b) ? a: b;} 1.77 +static inline int maxint(int a, int b) {return (a > b) ? a: b;} 1.78 + 1.79 +} // End namespace CLD2 1.80 + 1.81 +#endif // I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ 1.82 + 1.83 +