@@ -110,6 +110,38 @@ void fossil_jellyfish_dump(const fossil_jellyfish_chain *chain);
110110 */
111111void fossil_jellyfish_hash (const char *input, const char *output, uint8_t *hash_out);
112112
113+ /* *
114+ * Save the jellyfish chain to a file.
115+ * This serializes the chain to a file for persistence.
116+ *
117+ * @param chain Pointer to the jellyfish chain to save.
118+ * @param filepath The path to the file where the chain will be saved.
119+ * @return 0 on success, non-zero on failure.
120+ */
121+ int fossil_jellyfish_save (const fossil_jellyfish_chain *chain, const char *filepath);
122+
123+ /* *
124+ * Load a jellyfish chain from a file.
125+ * This deserializes the chain from a file.
126+ *
127+ * @param chain Pointer to the jellyfish chain to load.
128+ * @param filepath The path to the file from which the chain will be loaded.
129+ * @return 0 on success, non-zero on failure.
130+ */
131+ int fossil_jellyfish_load (fossil_jellyfish_chain *chain, const char *filepath);
132+
133+ /* *
134+ * Fuzzy reasoning for jellyfish AI.
135+ * This function attempts to find a close match for the input string
136+ * and returns the corresponding output if found.
137+ *
138+ * @param chain Pointer to the jellyfish chain.
139+ * @param input The input string to reason about.
140+ * @return The output string if a close match is found, or "Unknown" if not found.
141+ */
142+ const char * fossil_jellyfish_reason_fuzzy (fossil_jellyfish_chain *chain, const char *input);
143+
144+
113145#ifdef __cplusplus
114146}
115147#include < stdexcept>
@@ -209,6 +241,41 @@ namespace ai {
209241 fossil_jellyfish_init (&chain);
210242 }
211243
244+ /* *
245+ * Fuzzy reasoning for jellyfish AI.
246+ * This function attempts to find a close match for the input string
247+ * and returns the corresponding output if found.
248+ *
249+ * @param input The input string to reason about.
250+ * @return The output string if a close match is found, or "Unknown" if not found.
251+ */
252+ std::string reason_fuzzy (const std::string &input) {
253+ const char *result = fossil_jellyfish_reason_fuzzy (&chain, input.c_str ());
254+ return std::string (result);
255+ }
256+
257+ /* *
258+ * Save the jellyfish chain to a file.
259+ * This serializes the chain to a file for persistence.
260+ *
261+ * @param filepath The path to the file where the chain will be saved.
262+ * @return 0 on success, non-zero on failure.
263+ */
264+ int save (const std::string &filepath) const {
265+ return fossil_jellyfish_save (&chain, filepath.c_str ());
266+ }
267+
268+ /* *
269+ * Load a jellyfish chain from a file.
270+ * This deserializes the chain from a file.
271+ *
272+ * @param filepath The path to the file from which the chain will be loaded.
273+ * @return 0 on success, non-zero on failure.
274+ */
275+ int load (const std::string &filepath) {
276+ return fossil_jellyfish_load (&chain, filepath.c_str ());
277+ }
278+
212279 private:
213280 fossil_jellyfish_chain chain; // The jellyfish chain instance
214281 };
0 commit comments