Mercurial > libguess
view dfa.c @ 3:70e2c306231e
- implemented dfa utility functions.
- added dfa.c.
- rewrote guess functions for ar, gr, hw and tr scripts with dfa utilities.
- guess functions for cjk scripts too.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 12 Jun 2008 20:20:43 +0900 |
parents | |
children |
line wrap: on
line source
#include "libguess.h" #include "dfa.h" boolean dfa_alone(guess_dfa *dfa, guess_dfa *order[]) { int i; if (dfa->state < 0) return FALSE; for (i = 0; order[i] != NULL; i++) { if (order[i] != dfa && order[i]->state >= 0) { //DFA_ALIVE() return FALSE; } } return TRUE; } boolean dfa_none(guess_dfa *order[]) { int i; for (i = 0; order[i] != NULL; i++) { if (order[i]->state >= 0) { //DFA_ALIVE() return FALSE; } } return TRUE; } guess_dfa * dfa_top(guess_dfa *order[]) { int i; guess_dfa *top = NULL; for (i = 0; order[i] != NULL; i++) { if (order[i]->state >= 0) { //DFA_ALIVE() if (top == NULL || order[i]->score > top->score) top = order[i]; } } return top; } const char * dfa_process(guess_dfa *order[], int c) { int i; for (i = 0; order[i] != NULL; i++) { if (DFA_ALIVE_P(order[i])) { if (dfa_alone(order[i], order)) return order[i]->name; DFA_NEXT_P(order[i], c); } } }