From 0d49fb74eadcf933f696420cd182077927680d26 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 18 Jan 2017 19:09:16 +0100 Subject: Done with 'core', starting to work on 'knowledge'. --- src/knowledge/knowledge.h | 110 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/knowledge/knowledge.h (limited to 'src/knowledge/knowledge.h') diff --git a/src/knowledge/knowledge.h b/src/knowledge/knowledge.h new file mode 100644 index 0000000..51d94c4 --- /dev/null +++ b/src/knowledge/knowledge.h @@ -0,0 +1,110 @@ +#ifndef _ZoO_KNOWLEDGE_KNOWLEDGE_H_ +#define _ZoO_KNOWLEDGE_KNOWLEDGE_H_ + +#include "../core/char_types.h" +#include "../core/index_types.h" + +#include "knowledge_types.h" + +void ZoO_knowledge_initialize (struct ZoO_knowledge k [const restrict static 1]); + +void ZoO_knowledge_finalize (struct ZoO_knowledge k [const restrict static 1]); + +/* + * When returning 0: + * {word} was added to {k}, or was already there. + * {*result} indicates where {word} is in {k->words}. + * + * When returning -1: + * Something went wrong when adding the occurrence of {word} to {k}. + * {k} remains semantically unchanged. + * {*result} may or may not have been altered. + */ +int ZoO_knowledge_learn_word +( + struct ZoO_knowledge k [const static 1], + const ZoO_char word [const restrict static 1], + const ZoO_index word_length, + ZoO_index result [const restrict static 1] +); + +int ZoO_knowledge_learn_sequence +( + struct ZoO_knowledge k [const restrict static 1], + const ZoO_index sequence [const restrict static 1], + const ZoO_index sequence_length, + const ZoO_index markov_order +); + +int ZoO_knowledge_learn_markov_sequence +( + struct ZoO_knowledge k [const restrict static 1], + const ZoO_index sequence [const restrict static 1], + const ZoO_index sequence_length, + const ZoO_index markov_order +); + +int ZoO_knowledge_get_following_sequences_ref +( + const struct ZoO_knowledge k [const static 1], + const ZoO_index initial_word, + const ZoO_index * restrict following_sequences_ref [const restrict static 1], + const ZoO_index * restrict following_sequences_weights [const restrict static 1], + ZoO_index following_sequences_weights_sum [const static 1] +); + +int ZoO_knowledge_get_sequence +( + const struct ZoO_knowledge k [const static 1], + const ZoO_index sequences_ref, + const ZoO_index * restrict sequence [const restrict static 1] +); + +int ZoO_knowledge_get_word +( + const struct ZoO_knowledge k [const static 1], + const ZoO_index word_ref, + const ZoO_char * word [const restrict static 1], + size_t word_size [const restrict static 1] +); + +/* + * When returning 0: + * {word} is in {k}. + * {word} is located at {k->words[*result]}. + * + * When returning -1: + * {word} is not in {k}. + * {*result} is where {word} was expected to be found in + * {k->sorted_indices}. + */ +int ZoO_knowledge_find_word_id +( + const struct ZoO_knowledge k [const restrict static 1], + const ZoO_char word [const restrict static 1], + const size_t word_size, + ZoO_index result [const restrict static 1] +); + +int ZoO_knowledge_find_preceding_words +( + const struct ZoO_knowledge k [const static 1], + const ZoO_index sequence [const restrict], + const ZoO_index markov_order, + const ZoO_index * restrict preceding_words [const restrict static 1], + const ZoO_index * restrict preceding_words_weights [const restrict static 1], + ZoO_index preceding_words_weights_sum [const restrict static 1] +); + +int ZoO_knowledge_find_following_words +( + const struct ZoO_knowledge k [const static 1], + const ZoO_index sequence [const restrict], + const ZoO_index sequence_length, + const ZoO_index markov_order, + const ZoO_index * restrict following_words [const restrict static 1], + const ZoO_index * restrict following_words_weights [const restrict static 1], + ZoO_index following_words_weights_sum [const restrict static 1] +); + +#endif -- cgit v1.2.3-70-g09d2