• 大小: 64KB
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2021-08-06
  • 语言: 其他
  • 标签: Qt  谷歌拼音  

资源简介

这是安卓底层的谷歌拼音输入法源码,基于Qt5.4.2,win7平台。结合开发Qt5虚拟键盘插件使用。

资源截图

代码片段和文件信息

/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License Version 2.0 (the “License“);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing software
 * distributed under the License is distributed on an “AS IS“ BASIS
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include 
#include 
#include 
#include 

#include “dictbuilder.h“
#include “dicttrie.h“
#include “mystdlib.h“
#include “ngram.h“
#include “searchutility.h“
#include “spellingtable.h“
#include “spellingtrie.h“
#include “splparser.h“
#include “utf16reader.h“

namespace ime_pinyin {

#ifdef ___BUILD_MODEL___

static const size_t kReadBufLen = 512;
static const size_t kSplTableHashLen = 2000;

// Compare a SingleCharItem first by Hanzis then by spelling ids then by
// frequencies.
int cmp_scis_hz_splid_freq(const void* p1 const void* p2) {
  const SingleCharItem *s1 *s2;
  s1 = static_cast(p1);
  s2 = static_cast(p2);

  if (s1->hz < s2->hz)
    return -1;
  if (s1->hz > s2->hz)
    return 1;

  if (s1->splid.half_splid < s2->splid.half_splid)
    return -1;
  if (s1->splid.half_splid > s2->splid.half_splid)
    return 1;

  if (s1->splid.full_splid < s2->splid.full_splid)
    return -1;
  if (s1->splid.full_splid > s2->splid.full_splid)
    return 1;

  if (s1->freq > s2->freq)
    return -1;
  if (s1->freq < s2->freq)
    return 1;
  return 0;
}

int cmp_scis_hz_splid(const void* p1 const void* p2) {
  const SingleCharItem *s1 *s2;
  s1 = static_cast(p1);
  s2 = static_cast(p2);

  if (s1->hz < s2->hz)
    return -1;
  if (s1->hz > s2->hz)
    return 1;

  if (s1->splid.half_splid < s2->splid.half_splid)
    return -1;
  if (s1->splid.half_splid > s2->splid.half_splid)
    return 1;

  if (s1->splid.full_splid < s2->splid.full_splid)
    return -1;
  if (s1->splid.full_splid > s2->splid.full_splid)
    return 1;

  return 0;
}

int cmp_lemma_entry_hzs(const void* p1 const void* p2) {
  size_t size1 = utf16_strlen(((const LemmaEntry*)p1)->hanzi_str);
  size_t size2 = utf16_strlen(((const LemmaEntry*)p2)->hanzi_str);
  if (size1 < size2)
    return -1;
  else if (size1 > size2)
    return 1;

  return utf16_strcmp(((const LemmaEntry*)p1)->hanzi_str
                      ((const LemmaEntry*)p2)->hanzi_str);
}

int compare_char16(const void* p1 const void* p2) {
  if (*((const char16*)p1) < *((const char16*)p2))
    return -1;
  if (*((const char16*)p1) > *((const char16*)p2))
    return 1;
  return 0;
}

int compare_py(const void* p1 const void* p2) {
  int ret = utf16_strcmp(((const LemmaEntry*)p1)->sp

评论

共有 条评论