コード例 #1
0
ファイル: udiskslinuxprovider.c プロジェクト: GinoM/eudisk
static gint
device_name_cmp (const gchar *a,
                 const gchar *b)
{
  /* Ensures that sda comes before sdz%d and sdz%d comes before sdaa%d */
  if (g_str_has_prefix (a, "sd") && g_str_has_prefix (b, "sd"))
    {
      gint la = count_alphas (a);
      gint lb = count_alphas (b);
      if (la != lb)
        return la - lb;
      else
        return g_strcmp0 (a, b);
    }
  else
    {
      return g_strcmp0 (a, b);
    }
}
コード例 #2
0
ファイル: output.cpp プロジェクト: mehulsbhatt/MyOCRTEST
/*************************************************************************
 * SUSPECT LEVELS
 *
 * 0 - dont reject ANYTHING
 * 1,2 - partial rejection
 * 3 - BEST
 *
 * NOTE: to reject JUST tess failures in the .map file set suspect_level 3 and
 * tessedit_minimal_rejection.
 *************************************************************************/
    void Tesseract::set_unlv_suspects(WERD_RES * word_res) {
        int len = word_res->reject_map.length();
        const WERD_CHOICE &word = *(word_res->best_choice);
        const UNICHARSET &uchset = *word.unicharset();
        int i;
        float rating_per_ch;

        if (suspect_level == 0) {
            for (i = 0; i < len; i++) {
                if (word_res->reject_map[i].rejected())
                    word_res->reject_map[i].setrej_minimal_rej_accept();
            }
            return;
        }

        if (suspect_level >= 3)
            return;                      //Use defaults

        /* NOW FOR LEVELS 1 and 2 Find some stuff to unreject*/

        if (safe_dict_word(word_res) &&
            (count_alphas(word) > suspect_short_words)) {
            /* Unreject alphas in dictionary words */
            for (i = 0; i < len; ++i) {
                if (word_res->reject_map[i].rejected() &&
                    uchset.get_isalpha(word.unichar_id(i)))
                    word_res->reject_map[i].setrej_minimal_rej_accept();
            }
        }

        rating_per_ch = word.rating() / word_res->reject_map.length();

        if (rating_per_ch >= suspect_rating_per_ch)
            return;                      //Dont touch bad ratings

        if ((word_res->tess_accepted) || (rating_per_ch < suspect_accept_rating)) {
            /* Unreject any Tess Acceptable word - but NOT tess reject chs*/
            for (i = 0; i < len; ++i) {
                if (word_res->reject_map[i].rejected() &&
                    (!uchset.eq(word.unichar_id(i), " ")))
                    word_res->reject_map[i].setrej_minimal_rej_accept();
            }
        }

        for (i = 0; i < len; i++) {
            if (word_res->reject_map[i].rejected()) {
                if (word_res->reject_map[i].flag(R_DOC_REJ))
                    word_res->reject_map[i].setrej_minimal_rej_accept();
                if (word_res->reject_map[i].flag(R_BLOCK_REJ))
                    word_res->reject_map[i].setrej_minimal_rej_accept();
                if (word_res->reject_map[i].flag(R_ROW_REJ))
                    word_res->reject_map[i].setrej_minimal_rej_accept();
            }
        }

        if (suspect_level == 2)
            return;

        if (!suspect_constrain_1Il ||
            (word_res->reject_map.length() <= suspect_short_words)) {
            for (i = 0; i < len; i++) {
                if (word_res->reject_map[i].rejected()) {
                    if ((word_res->reject_map[i].flag(R_1IL_CONFLICT) ||
                         word_res->reject_map[i].flag(R_POSTNN_1IL)))
                        word_res->reject_map[i].setrej_minimal_rej_accept();

                    if (!suspect_constrain_1Il &&
                        word_res->reject_map[i].flag(R_MM_REJECT))
                        word_res->reject_map[i].setrej_minimal_rej_accept();
                }
            }
        }

        if (acceptable_word_string(*word_res->uch_set,
                                   word.unichar_string().string(),
                                   word.unichar_lengths().string()) !=
            AC_UNACCEPTABLE ||
            acceptable_number_string(word.unichar_string().string(),
                                     word.unichar_lengths().string())) {
            if (word_res->reject_map.length() > suspect_short_words) {
                for (i = 0; i < len; i++) {
                    if (word_res->reject_map[i].rejected() &&
                        (!word_res->reject_map[i].perm_rejected() ||
                         word_res->reject_map[i].flag(R_1IL_CONFLICT) ||
                         word_res->reject_map[i].flag(R_POSTNN_1IL) ||
                         word_res->reject_map[i].flag(R_MM_REJECT))) {
                        word_res->reject_map[i].setrej_minimal_rej_accept();
                    }
                }
            }
        }
    }