michael@0: // Copyright 2013 Google Inc. All Rights Reserved. michael@0: // michael@0: // Licensed under the Apache License, Version 2.0 (the "License"); michael@0: // you may not use this file except in compliance with the License. michael@0: // You may obtain a copy of the License at michael@0: // michael@0: // http://www.apache.org/licenses/LICENSE-2.0 michael@0: // michael@0: // Unless required by applicable law or agreed to in writing, software michael@0: // distributed under the License is distributed on an "AS IS" BASIS, michael@0: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: // See the License for the specific language governing permissions and michael@0: // limitations under the License. michael@0: michael@0: // michael@0: // Author: dsites@google.com (Dick Sites) michael@0: // michael@0: // Stuff used only by online detector, not used offline michael@0: // michael@0: michael@0: #ifndef I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ michael@0: #define I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ michael@0: michael@0: #include "cldutil_shared.h" michael@0: #include "scoreonescriptspan.h" michael@0: #include "tote.h" michael@0: michael@0: namespace CLD2 { michael@0: michael@0: // Score up to 64KB of a single script span in one pass michael@0: // Make a dummy entry off the end to calc length of last span michael@0: // Return offset of first unused input byte michael@0: int GetUniHits(const char* text, michael@0: int letter_offset, int letter_limit, michael@0: ScoringContext* scoringcontext, michael@0: ScoringHitBuffer* hitbuffer); michael@0: michael@0: // Score up to 64KB of a single script span, doing both delta-bi and michael@0: // distinct bis in one pass michael@0: void GetBiHits(const char* text, michael@0: int letter_offset, int letter_limit, michael@0: ScoringContext* scoringcontext, michael@0: ScoringHitBuffer* hitbuffer); michael@0: michael@0: // Score up to 64KB of a single script span in one pass michael@0: // Make a dummy entry off the end to calc length of last span michael@0: // Return offset of first unused input byte michael@0: int GetQuadHits(const char* text, michael@0: int letter_offset, int letter_limit, michael@0: ScoringContext* scoringcontext, michael@0: ScoringHitBuffer* hitbuffer); michael@0: michael@0: // Score up to 64KB of a single script span, doing both delta-octa and michael@0: // distinct words in one pass michael@0: void GetOctaHits(const char* text, michael@0: int letter_offset, int letter_limit, michael@0: ScoringContext* scoringcontext, michael@0: ScoringHitBuffer* hitbuffer); michael@0: michael@0: // Not sure if these belong here or in scoreonescriptspan.cc michael@0: int ReliabilityDelta(int value1, int value2, int gramcount); michael@0: int ReliabilityExpected(int actual_score_1kb, int expected_score_1kb); michael@0: michael@0: // Create a langprob packed value from its parts. michael@0: uint32 MakeLangProb(Language lang, int qprob); michael@0: michael@0: michael@0: void ProcessProbV2Tote(uint32 probs, Tote* tote); michael@0: michael@0: // Return score for a particular per-script language, or zero michael@0: int GetLangScore(uint32 probs, uint8 pslang); michael@0: michael@0: static inline int minint(int a, int b) {return (a < b) ? a: b;} michael@0: static inline int maxint(int a, int b) {return (a > b) ? a: b;} michael@0: michael@0: } // End namespace CLD2 michael@0: michael@0: #endif // I18N_ENCODINGS_CLD2_INTERNAL_NEW_CLDUTIL_H__ michael@0: michael@0: