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

📄 natural-selection-0.3.diff

📁 使用具有增量学习的监控式学习方法。包括几个不同的分类算法。
💻 DIFF
📖 第 1 页 / 共 3 页
字号:
+    return protocol_send (pd);+}+++int+protocol_c_unlearn_folder (protocol_c_data *pd, const char *class) {+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "unlearn:\"%s\"", class);+    return protocol_send (pd);+}+++static double_array *+protocol_get_scorelist (protocol_c_data *pd) {+    char *ch;+    int i;+    double_array *dl;++    if (strncmp (pd->bp, "s:", 2))+	return NULL;+    pd->bp += 2;+    i = strtol (pd->bp, &ch, 10);+    if (ch == pd->bp)+	return NULL;+    pd->bp = ch;+    if (*pd->bp != ':')+	return NULL;+    pd->bp++;++    dl = malloc (sizeof(double_array));+    if (!dl)+	return NULL;++    if (i < 1) {+	dl->array = NULL;+	dl->len = 0;+    } else {+	dl->array = malloc (i * sizeof(double));+	if (!dl->array) {+	    free (dl);+	    return NULL;+	}+	dl->len = i;+	for (i = 0; i < dl->len; i++) {+	    dl->array[i] = strtod (pd->bp, &ch);+	    pd->bp = ch;+	    pd->bp++;	// assert (pd->ibp == ';')+	}+    }++    if (*pd->bp != '\n') {+	free (dl->array);+	free (dl);+	return NULL;+    }+    pd->bp++;++    return dl;+}+++static int *+protocol_get_ranklist (protocol_c_data *pd) {+    char *ch;+    int i, j, *il;++    if (strncmp (pd->bp, "r:", 2))+	return NULL;++    pd->bp += 2;+    i = strtol (pd->bp, &ch, 10);+    pd->bp = ch;+    pd->bp++;	// assert (pd->ibp == ':')++    if (0 && i < 1) {	// FIXME+	il = NULL;+    } else {+	il = malloc ((i + 1) * sizeof(double));+	if (!il)+	    return NULL;+	for (j = 0; j < i; j++) {+	    il[j] = strtol(pd->bp, &ch, 10);+	    pd->bp = ch;+	    pd->bp++;	// assert (pd->ibp == ';')+	}+	il[j] = -1;+    }+    if (*pd->bp != '\n')+	fprintf(stderr, "Error in classification answer!\n");+    pd->bp++;++    return il;+}+++double_array *+protocol_c_classify_score (protocol_c_data *pd, const char *str) {+    int i;++    /* Send message */+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "classify:%s:s", str);+    i = protocol_send (pd);+    if (i)+	return NULL;++    /* Receive message */+    i = protocol_receive (pd);+    if (i)+	return NULL;++    return protocol_get_scorelist (pd);+}+++int *+protocol_c_classify_rank (protocol_c_data *pd, const char *str) {+    int i;++    /* Send request */+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "classify:%s:r", str);+    i = protocol_send (pd);+    if (i)+	return NULL;++    /* Receive answer */+    i = protocol_receive (pd);+    if (i)+	return NULL;++    return protocol_get_ranklist (pd);+}+++int+protocol_c_classify_top (protocol_c_data *pd, const char *str) {+    int i, *il;++    /* Send request */+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "classify:%s:t", str);+    i = protocol_send (pd);+    if (i)+	return -1;++    /* Receive answer */+    i = protocol_receive (pd);+    if (i)+	return -1;++    il = protocol_get_ranklist (pd);+    if (!il)+        return -1;+    i = il[0];+    free (il);++    return i;+}+++static str_array *+protocol_get_table (protocol_c_data *pd) {+    char *ch, **sl;+    int i, j, k;+    str_array *sa;++    sa = malloc (sizeof(str_array));+    if (!sa)+	return NULL;++    if (strncmp (pd->bp, "l:", 2))+	return NULL;++    pd->bp += 2;+    i = strtol (pd->bp, &ch, 10);+    pd->bp = ch;+    pd->bp++;	// assert (pd->bp == ':')++    if (i < 1) {+	sl = NULL;+    } else {+	sl = malloc (i * sizeof(char *));+	if (!sl)+	    return NULL;+	for (j = 0; j < i; j++) {+	    k = strtol (pd->bp, &ch, 10);+	    pd->bp = ch;+	    pd->bp++;	// assert (pd->bp == '=')+	    ch = strchr (pd->bp, ';');+	    // assert (ch != NULL)+	    sl[k] = malloc (ch - pd->bp + 1);+	    // assert (sl[i] != NULL)+	    memcpy (sl[k], pd->bp, ch - pd->bp);+	    sl[k][ch - pd->bp] = '\0';+	    pd->bp = ch + 1;+	}+    }+    if (*pd->bp != '\n')+	fprintf(stderr, "Error in table answer!\n");+    pd->bp++;++    sa->len = i;+    sa->array = sl;+    return sa;+}+++str_array *+protocol_c_get_table (protocol_c_data *pd, const char *key) {+    int i;++    /* Send request */+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "get:%s", key);+    i = protocol_send (pd);+    if (i)+	return NULL;++    /* Receive answer */+    i = protocol_receive (pd);+    if (i)+	return NULL;++    return protocol_get_table (pd);+}+++int+protocol_c_get_integer (protocol_c_data *pd, const char *key) {+   int i;+   char *ch;++    /* Send request */+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "get:%s", key);+    i = protocol_send (pd);+    if (i)+	return -1;++    /* Receive answer */+    i = protocol_receive (pd);+    if (i)+	return -1;++    i = strtol (pd->bp, &ch, 10);+    if (ch == pd->bp || *ch != '\n')+	return -1;+    pd->bp = ch + 1;++    return i;+}+++char *+protocol_c_get_string (protocol_c_data *pd, const char *key) {+    int i;+    char *res;++    /* Send request */+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "get:%s", key);+    i = protocol_send (pd);+    if (i)+	return NULL;++    /* Receive answer */+    i = protocol_receive (pd);+    if (i)+	return NULL;++    res = malloc (sizeof(char *) * (pd->len + 1));+    memcpy (res, pd->buf, pd->len);+    res[pd->len] = '\0';++    return res;+}+++int+protocol_c_set (protocol_c_data *pd, const char *key, const char *value) {+    int i;++    /* Send request */+    pd->bp = pd->buf;+    pd->bp += sprintf (pd->bp, "set:%s:%s", key, value);+    i = protocol_send (pd);+    if (i)+	return -1;++    /* Receive answer */+    i = protocol_receive (pd);+    if (i)+	return -1;++    // FIXME Check answer++    return 0;+}--- mail/protocol_c.h.orig	1970-01-01 01:00:00.000000000 +0100+++ mail/protocol_c.h	2003-02-13 17:32:12.000000000 +0100@@ -0,0 +1,71 @@+#ifndef PROTOCOL_C_H+#define PROTOCOL_C_H++typedef struct protocol_c_data_ protocol_c_data;++/**+ * Array of doubles.+ */+typedef struct {+    int len;		/**< Length of array */+    double *array;	/**< Array */+} double_array;++/**+ * Array of strings.+ */+typedef struct {+    int len;		/**< Length of array */+    char **array;	/**< Array */+} str_array;++protocol_c_data *+protocol_c_new (int len, const char *addr);++void+protocol_c_free (protocol_c_data *pd);++int+protocol_c_open (protocol_c_data *pd);++int+protocol_c_close (protocol_c_data *pd);++int+protocol_c_part (protocol_c_data *pd, const char *type, const char *charset,+		 const char *string, int len);++int+protocol_c_learn (protocol_c_data *pd, int class);++int+protocol_c_learn_folder (protocol_c_data *pd, const char *class);++int+protocol_c_unlearn (protocol_c_data *pd, int class);++int+protocol_c_unlearn_folder (protocol_c_data *pd, const char *class);++double_array *+protocol_c_classify_score (protocol_c_data *pd, const char *str);++int *+protocol_c_classify_rank (protocol_c_data *pd, const char *str);++int+protocol_c_classify_top (protocol_c_data *pd, const char *str);++str_array *+protocol_c_get_table (protocol_c_data *pd, const char *key);++int+protocol_c_get_integer (protocol_c_data *pd, const char *key);++char *+protocol_c_get_string (protocol_c_data *pd, const char *key);++int+protocol_c_set (protocol_c_data *pd, const char *key, const char *value);++#endif--- mail/select.c.orig	1970-01-01 01:00:00.000000000 +0100+++ mail/select.c	2003-02-13 17:32:12.000000000 +0100@@ -0,0 +1,283 @@+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */+/*+ * Copyright 2000,2001 Ximian, Inc. (www.ximian.com)+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of version 2 of the GNU General Public+ * License as published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307+ * USA+ */++/**+ * @file+ * Select interface for Evolution.+ *+ * @author  Mikael Ylikoski+ * @date    2002+ */++#include <ctype.h>+#include <stdio.h>+#include <string.h>+#include <sys/socket.h>+#include <sys/un.h>+#include <unistd.h>+#include <glib.h>+#include "camel/camel-folder.h"+#include "camel/camel-mime-message.h"+#include "camel/camel-store.h"+#include "camel/camel-private.h"+#include "camel/camel-stream.h"+#include "camel/camel-stream-mem.h"+#include "camel/camel-stream-filter.h"+#include "protocol_c.h"+#include "select.h"+#include "select-bar.h"++static GPtrArray* folders = NULL;	/** Maps folder numbers to folders */+static GHashTable* htab = NULL;		/** Maps folders to folder numbers */+static protocol_c_data *pdata = NULL;+++static GByteArray *+my_get_data_wrapper_text (CamelDataWrapper *wrapper)+{+	CamelStream *memstream;+	CamelStreamFilter *filtered_stream;+	GByteArray *ba;+	//char *text, *end;++	memstream = camel_stream_mem_new ();+	ba = g_byte_array_new ();+	camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba);+	filtered_stream = camel_stream_filter_new_with_stream (memstream);+	camel_object_unref (CAMEL_OBJECT (memstream));+	camel_data_wrapper_write_to_stream (wrapper,+					   CAMEL_STREAM (filtered_stream));+	camel_stream_flush (CAMEL_STREAM (filtered_stream));+	camel_object_unref (CAMEL_OBJECT (filtered_stream));+	/*

⌨️ 快捷键说明

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