⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rules.h

📁 dTree是一个运行在WinCE上的文件管理软件。类似文件管理器,功能强大
💻 H
字号:
/*----------------------------------------------------------------------  File    : rules.h  Contents: rule and rule set management  Author  : Christian Borgelt  History : 17.05.1998 file created            26.05.1998 functions r_supp and r_conf added            27.05.1998 comparison operator added            31.05.1998 operator coding changed            13.08.1998 parameter delas added to function rs_delete            24.08.1998 operators for value in subset added            26.08.1998 function rs_ruleexg added            19.07.2001 adapted to modified module scan            06.07.2002 rule and rule set parsing functions added            12.08.2004 adapted to new module parse----------------------------------------------------------------------*/#ifndef __RULES__#define __RULES__#ifdef RS_PARSE#include "parse.h"#endif#include "attset.h"/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*//* --- comparison operators (r_headadd, r_condadd) --- */#define R_EQ       0x0001       /* value is equal */#define R_LT       0x0002       /* value is less */#define R_GT       0x0004       /* value is greater */#define R_LE       (R_LT|R_EQ)  /* value is less    or equal */#define R_GE       (R_GT|R_EQ)  /* value is greater or equal */#define R_NE       (R_LT|R_GT)  /* value is not equal */#define R_IN       0x0008       /* value is in set */#define R_BF       0x0009       /* value is in set (bitflags) *//* --- rule set cut flags (rs_rulecut) --- */#define RS_COPY    AS_COPY      /* copy source rules */#define RS_ALL     AS_ALL       /* cut/copy all rules */#define RS_RANGE   AS_RANGE     /* cut/copy a range of rules *//* --- rule set description flags (rs_desc) --- */#define RS_TITLE   0x0001       /* print a title as a comment */#define RS_INFO    0x0002       /* print add. info. (as a comment) */#define RS_SUPP    0x0004       /* print the rule support */#define RS_CONF    0x0008       /* print the rule confidence */#define RS_CONDLN  0x0010       /* one condition per line *//*----------------------------------------------------------------------  Type Definitions----------------------------------------------------------------------*/typedef struct {                /* --- condition of a rule --- */  int          att;             /* attribute to test */  int          op;              /* comparison operator */  INST         val;             /* attribute value/value set */} COND;                         /* (rule condition) */typedef struct {                /* --- rule --- */  ATTSET       *attset;         /* underlying attribute set */  struct _rset *set;            /* containing rule set (if any) */  int          id;              /* identifier (index in rule set) */  float        supp;            /* support of the rule */  float        conf;            /* confidence of the rule */  COND         head;            /* head/consequent of the rule */  int          condvsz;         /* size of condition vector */  int          condcnt;         /* number of condition in vector */  COND         conds[1];        /* condition vector */} RULE;                         /* (rule) */typedef void RULE_DELFN (RULE *rule);  /* rule functions */typedef int  RULE_CMPFN (const RULE *r1, const RULE *r2, void *data);typedef struct _rset {          /* --- set of rules --- */  ATTSET       *attset;         /* underlying attribute set */  RULE_DELFN   *delfn;          /* rule deletion function */  int          rulevsz;         /* size of rule vector */  int          rulecnt;         /* number of rules in vector */  RULE         **rules;         /* rule vector */} RULESET;                      /* (rule set) *//*----------------------------------------------------------------------  Rule Functions----------------------------------------------------------------------*/extern RULE*    r_create    (ATTSET *attset, int maxcond);extern void     r_delete    (RULE *rule);extern int      r_copy      (RULE *dst,   RULE *src);extern ATTSET*  r_attset    (RULE *rule);extern float    r_setsupp   (RULE *rule,  float supp);extern float    r_getsupp   (RULE *rule);extern float    r_setconf   (RULE *rule,  float conf);extern float    r_getconf   (RULE *rule);extern int      r_headset   (RULE *rule,  int att, int op, INST *val);extern int      r_headatt   (RULE *rule);extern int      r_headop    (RULE *rule);extern CINST*   r_headval   (RULE *rule);extern int      r_condcnt   (RULE *rule);extern int      r_condadd   (RULE *rule,  int att, int op, INST *val);extern void     r_condrem   (RULE *rule,  int index);extern int      r_condatt   (RULE *rule,  int index);extern int      r_condop    (RULE *rule,  int index);extern CINST*   r_condval   (RULE *rule,  int index);extern void     r_condsort  (RULE *rule);extern int      r_check     (RULE *rule);#ifdef RS_PARSEextern RULE*    r_parse     (ATTSET *attset, SCAN *scan);#endif/*----------------------------------------------------------------------  Rule Set Functions----------------------------------------------------------------------*/extern RULESET* rs_create   (ATTSET  *attset, RULE_DELFN delfn);extern void     rs_delete   (RULESET *set, int delas);extern ATTSET*  rs_attset   (RULESET *set);extern int      rs_ruleadd  (RULESET *set, RULE *rule);extern RULE*    rs_rulerem  (RULESET *set, int ruleid);extern void     rs_ruleexg  (RULESET *set, int ruleid1, int ruleid2);extern void     rs_rulemove (RULESET *set, int offs, int cnt, int pos);extern int      rs_rulecut  (RULESET *dst, RULESET *src, int mode, ...);extern RULE*    rs_rule     (RULESET *set, int ruleid);extern int      rs_rulecnt  (RULESET *set);extern void     rs_sort     (RULESET *set, RULE_CMPFN cmpfn,void *data);extern int      rs_exec     (RULESET *set);#ifdef RS_DESCextern int      rs_desc     (RULESET *set, FILE *file,                             int mode, int maxlen);#endif#ifdef RS_PARSEextern RULESET* rs_parse    (ATTSET *attset, SCAN *scan);#endif/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*/#define r_attset(r)      ((r)->attset)#define r_setsupp(r,s)   ((r)->supp = (float)(s))#define r_getsupp(r)     ((r)->supp)#define r_setconf(r,c)   ((r)->conf = (float)(c))#define r_getconf(r)     ((r)->conf)#define r_headatt(r)     ((r)->head.att)#define r_headop(r)      (((r)->head.op)#define r_headval(r)     ((CINST*)&(r)->head.val)#define r_condcnt(r)     ((r)->condcnt)#define r_condatt(r,i)   ((r)->conds[i].att)#define r_condop(r,i)    (((r)->conds[i].op)#define r_condval(r,i)   ((CINST*)&(r)->conds[i].val)#define rs_attset(s)     ((s)->attset)#define rs_rule(s,i)     ((s)->rules[i])#define rs_rulecnt(s)    ((s)->rulecnt)#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -