WritRecogn-Types

WritRecogn-Types — Data types that frequently used in WritRecogn.

Stability Level

Stable, unless otherwise indicated

Synopsis



enum                RadicalType;
                    RadicalArray;
                    ProgramAssociate;
typedef             RadicalCode;
typedef             CoordTree;
typedef             RawStrokeNode;
typedef             Radical;
typedef             RawStroke;
typedef             AbsCharacter;
typedef             FullCharacter;
typedef             RadicalList;
#define             DEFAULT_RADICAL_GM_INDEX
typedef             RadicalGM;
#define             DEFAULT_RAWWRITING_INDEX
                    RawWriting;
#define             RADICAL                             (obj)
#define             RAWSTROKE                           (obj)
#define             ABSCHARACTER                        (obj)
#define             FULLCHARACTER                       (obj)
#define             RADICAL_GM                          (obj)
#define             RADICAL_LIST                        (obj)
enum                InputMethod;
                    InputCodeRec;
enum                SupportedLanguage;
typedef             LanguageSet;
enum                MainProgramCmd;
                    ProgFlags;
enum                TaskOutput;
#define             MAX_UNICHAR_CODE_LENGTH
#define             MAX_CHAR_CODE_LENGTH
typedef             Hypothesis;
typedef             CharacterMatcher;
typedef             StrokeNoiseReducer;
typedef             RadicalRecognizer;
typedef             SVM_MODEL;
typedef             SVM_PARAMETER;
typedef             SVM_PROBLEM;
typedef             SVM_NODE;
enum                RAW_STROKE_FEATURES;
typedef             SVM_FEATURES;
enum                RadicalField;
enum                QueryRelation;
                    RadicalQueryItem;
typedef             RadicalQuery;
typedef             SQLite;
typedef             CharacterDataFile;
                    ProgressData;
                    TrainingProgressData;
TrainingProgressData* (*TrainingProgressFunc)           (RadicalRecognizer *recognizer,
                                                         RadicalList *radicalList);
#define             CHARACTER_DATAFILE                  (obj)
enum                DisplayMode;

Description

This header file hold frequently used data types, as well as many convenient aliases.

Details

enum RadicalType

typedef enum  {
    RADICAL_TYPE_RADICAL,
    RADICAL_TYPE_RAWSTROKE,
    RADICAL_TYPE_ABSCHARACTER, 
    RADICAL_TYPE_FULLCHARACTER,
} RadicalType;

An enumeration of radical type. Usually used to indicate the desired type of radical to be returned, or type of radicals that radical array stores.

RADICAL_TYPE_RADICAL

Indicates the radical type is radical.

RADICAL_TYPE_RAWSTROKE

Indicates the radical type is raw stroke.

RADICAL_TYPE_ABSCHARACTER

Indicate the radical type is abstract character.

RADICAL_TYPE_FULLCHARACTER

Indicate the radical type is full character.

RadicalArray

typedef struct {
    RadicalType type;
    GPtrArray *radArray;
} RadicalArray;

The RadicalArray struct contains the public fields of a Radical Array.

see_also: WritRecogn-RadicalArray

RadicalType type;

Type of radical this array stores. See RadicalType for details

GPtrArray *radArray;

The array of radical pointers

ProgramAssociate

typedef struct {
    MainProgramCmd progCmd;
    Subroutine subroutine;
    ProgFlags flags;
    gchar *usageMsg;
    DisplayMode displayMode;

    RadicalList *currRadicalList;
    CharacterMatcher *charMatcher;
    RadicalRecognizer *recognizer;
    StrokeNoiseReducer *strokeNoiseReducer;

    CharacterDataFile *characterDataFile;
    gchar characterDataFileName[PATH_MAX];
    gchar strokeHypothesisFileName[PATH_MAX];

    ChooseFilenameFunc choose_open_callback;
    ChooseFilenameFunc choose_save_callback;

    TrainingProgressFunc training_progress_callback;
} ProgramAssociate;

Program associate stores global parameters and variables.


RadicalCode

typedef glong RadicalCode;

Radical code type definition.


CoordTree

typedef GTree CoordTree;

Tree of sorted integer pairs which represent bounding points. It is mainly for Relative Radical Bounding Box.


RawStrokeNode

typedef Coordinate2D RawStrokeNode;

Data structure for a 2-D point which represent node of handwriting stroke.


Radical

typedef struct _writRecognRadical Radical;

A short alias of writRecognRadical.


RawStroke

typedef struct _writRecognRawStroke RawStroke;

A short alias of writRecognRawStroke.


AbsCharacter

typedef struct _writRecognAbsCharacter AbsCharacter;

A short alias of writRecognAbsCharacter.


FullCharacter

typedef struct _writRecognFullCharacter FullCharacter;

A short alias of writRecognFullCharacter.,


RadicalList

typedef struct _writRecognRadical_list RadicalList;

A short alias of writRecognRadical_list.


DEFAULT_RADICAL_GM_INDEX

#define DEFAULT_RADICAL_GM_INDEX 0

Default radical geometry model index.


RadicalGM

typedef struct _writRecognRadical_geometry_model RadicalGM;

A short alias of writRecognRadical_geometry_model.


DEFAULT_RAWWRITING_INDEX

#define DEFAULT_RAWWRITING_INDEX 0

Default raw writing index.


RawWriting

typedef struct {
    gint writingId;
    RadicalArray *rStrokeArray;
} RawWriting;

A RawWriting instance demonstrates how this character are written by a user.

gint writingId;

a serial number that identifies a RawWriting, start at 1.

RadicalArray *rStrokeArray;

a radical array that shows how a character is formed by RawStrokes.

RADICAL()

#define RADICAL(obj) WRITRECOGN_RADICAL(obj)

Cast the given object as Radical.

obj :

the object to be casted.

RAWSTROKE()

#define RAWSTROKE(obj) WRITRECOGN_RAWSTROKE(obj)

Cast the given object as RawStroke.

obj :

the object to be casted

ABSCHARACTER()

#define ABSCHARACTER(obj) WRITRECOGN_ABSCHARACTER(obj)

Cast the given object as AbsCharacter.

obj :

the object to be casted.

FULLCHARACTER()

#define FULLCHARACTER(obj) WRITRECOGN_FULLCHARACTER(obj)

Cast the given object as FullCharacter.

obj :

the object to be casted.

RADICAL_GM()

#define RADICAL_GM(obj) WRITRECOGN_RADICAL_GEOMETRY_MODEL(obj)

Cast the given object as RadicalGM.

obj :

the object to be casted.

RADICAL_LIST()

#define RADICAL_LIST(obj) WRITRECOGN_RADICAL_LIST(obj)

Cast the given object as RadicalList.

obj :

the object to be casted.

enum InputMethod

typedef enum{
    STROKE_SEQUENCE,
    WUBI98,
    IM_OTHER,
    IM_NOT_SPECIFIED,
    IM_INVALID,
} InputMethod;

An enumeration for input method.

STROKE_SEQUENCE

Stroke Sequence input method.

WUBI98

Wubi 98 input method.

IM_OTHER

Other input method.

IM_NOT_SPECIFIED

Don't care which input method. Used in query.

IM_INVALID

Not a valid input method. Used as error return code.

InputCodeRec

typedef struct {
    InputMethod method;
    gchar *inputCode;
} InputCodeRec;

An input code record consists the input code and its corresponding input method.

InputMethod method;

Input method

gchar *inputCode;

Input code.

enum SupportedLanguage

typedef enum  {
    LANG_UNLABELED=0,
    LANG_NUMBER,
    LANG_SYMBOL,
    LANG_EN,
    LANG_JP,
    LANG_KR,
    LANG_ZH_SIMPLIFIED,
    LANG_ZH_TRADITIONAL,
} SupportedLanguage;

An enumeration for supported language. Note that a character might be multi-labeled.

LANG_UNLABELED

The character does not appear in any supported language.

LANG_NUMBER

The character is numerical.

LANG_SYMBOL

The character is a symbol.

LANG_EN

The character is an English alphabet.

LANG_JP

The character appears in Japanese.

LANG_KR

The character appears in Korean.

LANG_ZH_SIMPLIFIED

The character appears in simplified Chinese.

LANG_ZH_TRADITIONAL

The character appears in traditional Chinese.

LanguageSet

typedef GArray LanguageSet;

Set of supported languages. Because character might appears in multiple languages. For example, character 天 appears in Japanese, simplified and traditional Chinese.

see_also: SupportedLanguage.


enum MainProgramCmd

typedef enum{
    RECOGNIZER=0,
    CHARACTER_DATA_MANAGER
} MainProgramCmd;

An enumeration of main program

RECOGNIZER

The main program is a recognizer (e.g. WritRecogn).

CHARACTER_DATA_MANAGER

The main program is a character data manager recognizer (e.g. WritRecogn-manager).

ProgFlags

typedef struct {
    unsigned guiFlag: 1;
    unsigned trainingFlag: 1;
    unsigned characterDataModified: 1;
    unsigned hypothesisModified: 1;
    unsigned canvasModified: 1;
    /**
     * FALSE before gtk_widget_show(mainWindowWidget); TRUE otherwise.
     */
    unsigned initializedFlag: 1; 
} ProgFlags;

Status flags for ProgramAssociate.


enum TaskOutput

typedef enum{
    TASK_RUNNING,
    TASK_CANCELED,
    TASK_FAILED,
    TASK_COMPLETED
} TaskOutput;

An enumeration of task running status.

TASK_RUNNING

The task is running

TASK_CANCELED

The task is canceled.

TASK_FAILED

The task is failed.

TASK_COMPLETED

The task is completed.

MAX_UNICHAR_CODE_LENGTH

#define MAX_UNICHAR_CODE_LENGTH 7


MAX_CHAR_CODE_LENGTH

#define MAX_CHAR_CODE_LENGTH MAX_UNICHAR_CODE_LENGTH*10


Hypothesis

typedef gpointer *Hypothesis;

Stroke recognition hypothesis.


CharacterMatcher

typedef struct _writRecognCharacter_matcher CharacterMatcher;

A short alias of writRecognCharacter_matcher.


StrokeNoiseReducer

typedef struct _writRecognStroke_noise_reducer StrokeNoiseReducer;

A short alias of writRecognStroke_noise_reducer.


RadicalRecognizer

typedef struct _writRecognRadical_recognizer RadicalRecognizer;	

A short alias of writRecognRadical_recognizer.


SVM_MODEL

typedef struct svm_model SVM_MODEL;

A short alias of svm_model.


SVM_PARAMETER

typedef struct svm_parameter SVM_PARAMETER;

A short alias of svm_parameter.


SVM_PROBLEM

typedef struct svm_problem SVM_PROBLEM;

A short alias of svm_problem.


SVM_NODE

typedef struct svm_node SVM_NODE;

A short alias of svm_node.


enum RAW_STROKE_FEATURES

typedef enum {
    NUM_OF_MIDDLE_RAW_STROKE_NODE = 1,
    FARTHEST_DISTANCE,
    DEPRESSION_ANGLE,
    //    DIRECT_LENGTH,
} RAW_STROKE_FEATURES;

An enumeration of raw stroke features which are considered in stroke recognition. Chord is the line segment from starting stroke node to ending stroke node.

NUM_OF_MIDDLE_RAW_STROKE_NODE

Number of non-ended stroke nodes in stroke,

FARTHEST_DISTANCE

The farthest distance between stroke node and chord.

DEPRESSION_ANGLE

The depression angle of chord

SVM_FEATURES

typedef GArray SVM_FEATURES;	///< feature-array as input of libSVM.


enum RadicalField

typedef enum {
    RADICAL_FIELD_RADICAL_CODE,
    RADICAL_FIELD_INPUT_METHOD,
    RADICAL_FIELD_INPUT_CODE,
    RADICAL_FIELD_LANG,
    RADICAL_FIELD_VAR_RADICAL,
} RadicalField;

An enumeration of search field types. RadicalQuery.

RADICAL_FIELD_RADICAL_CODE

Indicate the field is radical code.

RADICAL_FIELD_INPUT_METHOD

Indicate the field is input method.

RADICAL_FIELD_INPUT_CODE

Indicate the field is input code.

RADICAL_FIELD_LANG

Indicate the field is input code.

RADICAL_FIELD_VAR_RADICAL

Indicate the filed is radical code of variant character.

enum QueryRelation

typedef enum  {
    QUERY_RELATION_EQUAL,
    QUERY_RELATION_NOT_EQUAL,
    QUERY_RELATION_LESS_THAN,
    QUERY_RELATION_LESS_OR_EQUAL,
    QUERY_RELATION_GREATER_THAN,
    QUERY_RELATION_GREATER_OR_EQUAL,
} QueryRelation;

An enumeration of query relation. Used with RadicalQuery.

QUERY_RELATION_EQUAL

The field value equals to the given value.

QUERY_RELATION_NOT_EQUAL

The field value does not equal to the given value.

QUERY_RELATION_LESS_THAN

The field value is less than the given value.

QUERY_RELATION_LESS_OR_EQUAL

The field value is less than or equals to the given value.

QUERY_RELATION_GREATER_THAN

The field value is greater than the given value.

QUERY_RELATION_GREATER_OR_EQUAL

The field value is greater than or equals to the given value.

RadicalQueryItem

typedef struct {
    RadicalField field;
    QueryRelation relation;
    gchar* value;
} RadicalQueryItem;

A sub query which contains the selection criteria.

RadicalField field;

The data file field.

QueryRelation relation;

The relation between the field value and value.

gchar *value;

The value for the selection criteria.

RadicalQuery

typedef GArray RadicalQuery;

A set query items for locating matched data.


SQLite

typedef sqlite3 SQLite;

A short alias of sqlite3.


CharacterDataFile

typedef struct _writRecognCharacter_datafile CharacterDataFile;

A short alias of writRecognCharacter_datafile.


ProgressData

typedef struct {
    int timer;
    TaskOutput result;
    gboolean restart;
    GtkWidget *window;
    GtkWidget *pbar;
} ProgressData;

Data structure necessary to show current progress. Used in a progress bar.

int timer;

timer for timeout.

TaskOutput result;

the running status of a thread.

gboolean restart;

whether the progress has been started.

GtkWidget *window;

the dialog window widget.

GtkWidget *pbar;

the progress bar widget.

TrainingProgressData

typedef struct {
    ProgressData pdata;
    Hypothesis *hypo;
} TrainingProgressData;

Data structure for showing current training progress.

ProgressData pdata;

progress data.

Hypothesis *hypo;

generated hypothesis.

TrainingProgressFunc ()

TrainingProgressData* (*TrainingProgressFunc)           (RadicalRecognizer *recognizer,
                                                         RadicalList *radicalList);

A prototype for training progress functions such as hypothesis training.

recognizer :

stroke recognizer

radicalList :

radical list.

Returns :

the data of training progress.

CHARACTER_DATAFILE()

#define CHARACTER_DATAFILE(obj) WRITRECOGN_CHARACTER_DATAFILE(obj)

Cast object as CharacterDataFile

obj :

object to be casted.

enum DisplayMode

typedef enum{
    RECOGNIZING_MODE,
    TRAINING_MODE,
    UNIHAN_MODE
} DisplayMode;

An enumeration of canvas and menu display mode.

RECOGNIZING_MODE

canvas shows user-drawn strokes, but not background character. Save functions are disabled.

TRAINING_MODE

canvas shows strokes from database,background characters are from pagno (installed fonts). Save functions are enabled.

UNIHAN_MODE

canvas shows strokes from database, background characters are from UniHan. Save functions are enabled.