1
1
/*
2
- This is part of pyahocorasick Python module.
2
+ This is part of pyahocorasick Python module.
3
3
4
- Automaton class methods
4
+ Automaton class methods
5
5
6
6
Author : Wojciech Muła, [email protected]
7
7
WWW : http://0x80.pl
14
14
#include "trie.h"
15
15
16
16
typedef enum {
17
- EMPTY = 0 ,
18
- TRIE = 1 ,
19
- AHOCORASICK = 2
17
+ EMPTY = 0 ,
18
+ TRIE = 1 ,
19
+ AHOCORASICK = 2
20
20
} AutomatonKind ;
21
21
22
22
@@ -25,9 +25,9 @@ check_kind(const int kind);
25
25
26
26
27
27
typedef enum {
28
- STORE_INTS = 10 ,
29
- STORE_LENGTH = 20 ,
30
- STORE_ANY = 30
28
+ STORE_INTS = 10 ,
29
+ STORE_LENGTH = 20 ,
30
+ STORE_ANY = 30
31
31
} KeysStore ;
32
32
33
33
@@ -36,7 +36,7 @@ check_store(const int store);
36
36
37
37
38
38
typedef enum {
39
- KEY_STRING = 100 ,
39
+ KEY_STRING = 100 ,
40
40
KEY_SEQUENCE = 200
41
41
} KeyType ;
42
42
@@ -46,47 +46,47 @@ check_key_type(const int key_type);
46
46
47
47
48
48
struct Input {
49
- Py_ssize_t wordlen ;
50
- TRIE_LETTER_TYPE * word ;
51
- PyObject * py_word ;
52
- bool is_copy ;
49
+ Py_ssize_t wordlen ;
50
+ TRIE_LETTER_TYPE * word ;
51
+ PyObject * py_word ;
52
+ bool is_copy ;
53
53
};
54
54
55
55
56
56
typedef struct AutomatonStatistics {
57
- int version ;
58
-
59
- ssize_t nodes_count ; ///< total number of nodes
60
- ssize_t words_count ; ///< len(automaton)
61
- ssize_t longest_word ; ///< longest word
62
- ssize_t links_count ; ///< links count
63
- ssize_t sizeof_node ; ///< size of single node (a C structure)
64
- ssize_t total_size ; ///< total size in bytes
57
+ int version ;
58
+
59
+ ssize_t nodes_count ; ///< total number of nodes
60
+ ssize_t words_count ; ///< len(automaton)
61
+ ssize_t longest_word ; ///< longest word
62
+ ssize_t links_count ; ///< links count
63
+ ssize_t sizeof_node ; ///< size of single node (a C structure)
64
+ ssize_t total_size ; ///< total size in bytes
65
65
} AutomatonStatistics ;
66
66
67
67
68
68
typedef struct Automaton {
69
- PyObject_HEAD
69
+ PyObject_HEAD
70
70
71
- AutomatonKind kind ; ///< current kind of automaton
72
- KeysStore store ; ///< type of values: copy of string, bare integer, python object
71
+ AutomatonKind kind ; ///< current kind of automaton
72
+ KeysStore store ; ///< type of values: copy of string, bare integer, python object
73
73
KeyType key_type ; ///< type of keys: strings or integer sequences
74
- int count ; ///< number of distinct words
75
- int longest_word ; ///< length of the longest word
76
- TrieNode * root ; ///< root of a trie
74
+ int count ; ///< number of distinct words
75
+ int longest_word ; ///< length of the longest word
76
+ TrieNode * root ; ///< root of a trie
77
77
78
- int version ; ///< current version of automaton, incremented by add_word, clean and make_automaton; used to lazy invalidate iterators
78
+ int version ; ///< current version of automaton, incremented by add_word, clean and make_automaton; used to lazy invalidate iterators
79
79
80
- AutomatonStatistics stats ; ///< statistics
80
+ AutomatonStatistics stats ; ///< statistics
81
81
} Automaton ;
82
82
83
83
/*------------------------------------------------------------------------*/
84
84
85
85
static bool
86
86
automaton_unpickle (
87
- Automaton * automaton ,
88
- PyObject * bytes_list ,
89
- PyObject * values
87
+ Automaton * automaton ,
88
+ PyObject * bytes_list ,
89
+ PyObject * values
90
90
);
91
91
92
92
static PyObject *
0 commit comments