亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wi2dvf.c

?? 貝葉斯學習算法分類文本?;跇闼刎惾~斯分類器的文本分類的通用算法
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* Word-index to document-vector-file *//* Copyright (C) 1997 Andrew McCallum   Written by:  Andrew Kachites McCallum <mccallum@cs.cmu.edu>   This file is part of the Bag-Of-Words Library, `libbow'.   This library is free software; you can redistribute it and/or   modify it under the terms of the GNU Library General Public License   as published by the Free Software Foundation, version 2.      This library 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   Library General Public License for more details.   You should have received a copy of the GNU Library General Public   License along with this library; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA */#include <bow/libbow.h>#include <netinet/in.h>		/* for machine-independent byte-order */#include <assert.h>#define INIT_BOW_DVF(DVF) { DVF.seek_start = -1; DVF.dv = NULL; }unsigned int bow_wi2dvf_default_capacity = 1024;bow_wi2dvf *bow_wi2dvf_new (int capacity){  bow_wi2dvf *ret;  int i;  if (capacity == 0)    capacity = bow_wi2dvf_default_capacity;  ret = bow_malloc (sizeof (bow_wi2dvf) + (sizeof (bow_dvf) * capacity));  ret->size = capacity;  ret->num_words = 0;  ret->fp = NULL;  for (i = 0; i < capacity; i++)    INIT_BOW_DVF(ret->entry[i]);  return ret;}/* xxx We should think about a scheme that doesn't require keeping all   the "document vectors" in core at the time time.  We could write   them to disk, read them back in when we needed to add to them, then   write them back out again.  We would need a nice caching scheme, as   well as nice way to deal with "document vectors" that grow. *//* Add a "word vector" WV, associated with "document index" DI, to    the map WI2DVF. */ voidbow_wi2dvf_add_di_wv (bow_wi2dvf **wi2dvf, int di, bow_wv *wv){  int i, wi;  int max_wi = bow_num_words ();  if (max_wi > (*wi2dvf)->size)    {      /* There are so many unique words, we need to grow the array	 that maps WI's to DVF's. */      int wi = (*wi2dvf)->size;	        /* a "word index" */      (*wi2dvf)->size = MAX (max_wi, (*wi2dvf)->size * 2);      (*wi2dvf) = bow_realloc (*wi2dvf, 			       (sizeof (bow_wi2dvf)				+ (sizeof (bow_dvf) * (*wi2dvf)->size)));      /* Initialize the new part of the realloc'ed space. */      for ( ; wi < (*wi2dvf)->size; wi++)	INIT_BOW_DVF((*wi2dvf)->entry[wi]);    }  /* Run down the "word vector", depositing each entry in the WI2DVF. */  for (i = 0; i < wv->num_entries; i++)    {      wi = wv->entry[i].wi;      assert ((*wi2dvf)->size > wi);      if ((*wi2dvf)->entry[wi].dv == NULL)	{	  /* There is not yet a "document vector" for "word index" WI,	     so create one. */	  (*wi2dvf)->entry[wi].dv = bow_dv_new (0);	  /* This 2 is a flag to the hide/unhide code that this DV exists. */	  (*wi2dvf)->entry[wi].seek_start = 2;	  ((*wi2dvf)->num_words)++;	}      /* Add the "document index" DI and the count associated with         word index WI to the WI'th "document vector". */      /* xxx Should we be adding WV->ENTRY[i].WEIGHT also? */      bow_dv_add_di_count_weight (&((*wi2dvf)->entry[wi].dv), di,				  wv->entry[i].count, 0);    }}/* Read all the words from file pointer FP, and add them to WI2DVF,   associated with document index DI. */voidbow_wi2dvf_add_di_text_fp (bow_wi2dvf **wi2dvf, int di, FILE *fp){  char word[BOW_MAX_WORD_LENGTH]; /* buffer for reading and stemming words */  int wi;			/* a word index */  bow_lex *lex;  /* Loop once for each document in this file. */  while ((lex = bow_default_lexer->open_text_fp (bow_default_lexer, fp)))    {      /* Loop once for each lexical token in this document. */      while (bow_default_lexer->get_word (bow_default_lexer,					  lex, word, BOW_MAX_WORD_LENGTH))	{	  /* Find out the word's "index". */	  wi = bow_word2int_add_occurrence (word);	  if (wi < 0)	    continue;	  /* Increment our stats about this word/document pair. */	  bow_wi2dvf_add_wi_di_count_weight (wi2dvf, wi, di, 1, 0);	}      bow_default_lexer->close (bow_default_lexer, lex);    }}/* In the map WI2DVF, increase by COUNT and WEIGHT our record of the   number times and weight that the document with "document index" DI   contains the word with "word index" WI. */voidbow_wi2dvf_add_wi_di_count_weight (bow_wi2dvf **wi2dvf, int wi,				   int di, int count, float weight){  if (wi >= (*wi2dvf)->size)    {      /* There are so many unique words, we need to grow the array	 that maps WI's to DVF's. */      int old_size = (*wi2dvf)->size; /* a "word vector" */      (*wi2dvf)->size = MAX (wi+1, (*wi2dvf)->size * 2);      (*wi2dvf) = bow_realloc (*wi2dvf, 			       (sizeof (bow_wi2dvf)				+ (sizeof (bow_dvf) * (*wi2dvf)->size)));      /* Initialize the new part of the realloc'ed space. */      for ( ; old_size < (*wi2dvf)->size; old_size++)	INIT_BOW_DVF((*wi2dvf)->entry[old_size]);    }   /* Increment the stats for the WI/DI pair. */  if ((*wi2dvf)->entry[wi].dv == NULL)    {      /* There is not yet a "document vector" for "word index" WI,	 so create one. */      (*wi2dvf)->entry[wi].dv = bow_dv_new (0);      /* This 2 is a flag to the hide/unhide code that this DV exists. */      (*wi2dvf)->entry[wi].seek_start = 2;      ((*wi2dvf)->num_words)++;    }  /* Add the "document index" DI and the count associated with     word index WI to the WI'th "document vector". */  bow_dv_add_di_count_weight (&((*wi2dvf)->entry[wi].dv), di, count, weight);}/* Return a pointer to the BOW_DE for a particular word/document pair,    or return NULL if there is no entry for that pair. */bow_de *bow_wi2dvf_entry_at_wi_di (bow_wi2dvf *wi2dvf, int wi, int di){  bow_dv *dv = bow_wi2dvf_dv (wi2dvf, wi);  if (!dv)    return NULL;  return bow_dv_entry_at_di (dv, di);}/* Remove the word with index WI from the vocabulary of the map WI2DVF */voidbow_wi2dvf_remove_wi (bow_wi2dvf *wi2dvf, int wi){  assert (wi < wi2dvf->size);  if (wi2dvf->entry[wi].dv)    {      bow_dv_free (wi2dvf->entry[wi].dv);      (wi2dvf->num_words)--;    }  INIT_BOW_DVF (wi2dvf->entry[wi]);}#define FREE_WHEN_HIDING_WI 0/* Temporarily hide the word with index WI from the vocabulary of the   map WI2DVF. The function BOW_WI2DVF_DV() will no longer see the entry   for this WI, but */voidbow_wi2dvf_hide_wi (bow_wi2dvf *wi2dvf, int wi){  assert (wi < wi2dvf->size);#if FREE_WHEN_HIDING_WI  if (wi2dvf->entry[wi].dv)    {      bow_dv_free (wi2dvf->entry[wi].dv);      /* (wi2dvf->num_words)--; */    }  wi2dvf->entry[wi].dv = NULL;#endif  /* The token -1 is reserved to mean that the DV is uninitialized. */  assert (!(wi2dvf->entry[wi].dv && wi2dvf->entry[wi].seek_start == -1));  /* Make the SEEK_START negative so we won't use it in normal situations,     but will be able to remember it and get it back when we need it. */  if (wi2dvf->entry[wi].seek_start > 0)    {      wi2dvf->entry[wi].seek_start = - (wi2dvf->entry[wi].seek_start);      (wi2dvf->num_words)--;    }}/* Make visible all DVF's that were hidden with BOW_WI2DVF_HIDE_WI(). */voidbow_wi2dvf_unhide_all_wi (bow_wi2dvf *wi2dvf){  int wi;  for (wi = 0; wi < wi2dvf->size; wi++)    {      if (wi2dvf->entry[wi].seek_start < -1)	{	  wi2dvf->entry[wi].seek_start = - (wi2dvf->entry[wi].seek_start);	  (wi2dvf->num_words)++;	}    }}/* Write WI2DVF to file-pointer FP, in a machine-independent format.   This is the format expected by bow_wi2dvf_new_from_fp(). */voidbow_wi2dvf_write (bow_wi2dvf *wi2dvf, FILE *fp){  long seek_base;  long seek_current;  int wi;  bow_wi2dvf_unhide_all_wi (wi2dvf);  /* Figure out how many bytes the WI2DVF (without the DV's) will     take at the beginning the file. */  seek_base =     (ftell (fp)			/* Where we are starting */     + (sizeof (int)		/* for the number of "word indices" */	+ (sizeof (int)		/* for each SEEK_START value */	   * wi2dvf->size)));	/* multiplied by the number of WI's */  /* Write the maximum "word index". */  bow_fwrite_int (wi2dvf->size, fp);  /* Figure out the correct SEEK_START values for all the DVF's,     set them in the DVF's data structure, and write out the DVF's     SEEK_START information. */  for (wi = 0, seek_current = seek_base; wi < wi2dvf->size; wi++)    {      if (wi2dvf->entry[wi].dv == NULL)	{	  /* Write an indication of a NULL document vector. */	  bow_fwrite_int (-1, fp);	  /* Set the SEEK_START in the data structure. */	  wi2dvf->entry[wi].seek_start = -1;	}      else	{	  /* Write the DVF's SEEK_START info. */	  bow_fwrite_int (seek_current, fp);	  /* Set the SEEK_START in the data structure. */	  wi2dvf->entry[wi].seek_start = seek_current;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美视频一区在线观看| 国产精品私人影院| 久久久91精品国产一区二区精品| 国产精品久久久久久福利一牛影视 | 天天色图综合网| 国产一区二区看久久| 欧美日韩一级黄| 国产精品免费网站在线观看| 久久不见久久见中文字幕免费| 色综合久久66| 精品国产精品一区二区夜夜嗨| 亚洲最大成人综合| 福利电影一区二区| 欧美mv日韩mv亚洲| 日韩va欧美va亚洲va久久| 成人激情文学综合网| 日韩精品中文字幕一区二区三区| 一区二区三区免费| av在线这里只有精品| 久久嫩草精品久久久精品一| 激情欧美一区二区三区在线观看| 欧美综合在线视频| 亚洲视频一区二区在线观看| 成人h动漫精品一区二区 | 欧美在线免费播放| 国产精品福利一区二区三区| 国产激情一区二区三区| 日韩免费看的电影| 免费观看在线色综合| 51午夜精品国产| 天天综合天天做天天综合| 色偷偷88欧美精品久久久| 亚洲色图丝袜美腿| 99精品久久久久久| 中文字幕欧美国产| 国产成人综合自拍| 国产视频在线观看一区二区三区 | 亚洲成人免费视| 欧洲精品在线观看| 亚洲综合小说图片| 欧美日韩一级二级| 日韩中文字幕区一区有砖一区| 欧美日韩aaa| 日韩精品乱码免费| 精品久久一区二区| 国产精品99久久久久久久女警 | 精品99999| 经典三级一区二区| 久久午夜色播影院免费高清| 粉嫩av亚洲一区二区图片| 欧美国产丝袜视频| 色婷婷av一区| 日本在线不卡视频| 久久久欧美精品sm网站| 国产aⅴ精品一区二区三区色成熟| 国产色综合久久| 91麻豆免费看片| 污片在线观看一区二区| 欧美大片一区二区| 成人av网址在线| 亚洲成人你懂的| wwwwxxxxx欧美| 97精品超碰一区二区三区| 亚洲一区二区三区视频在线| 欧美一级久久久久久久大片| 成人在线综合网| 午夜日韩在线观看| 国产肉丝袜一区二区| 色婷婷综合激情| 精品一区二区三区在线播放视频| 日本一二三四高清不卡| 欧美日韩夫妻久久| 国产成人aaa| 亚洲va欧美va人人爽午夜| 久久久久久久久久久久久女国产乱| 91在线观看成人| 蜜桃精品视频在线观看| 亚洲四区在线观看| 日韩视频一区二区三区在线播放 | 欧美日韩一区小说| 国产高清视频一区| 午夜久久久影院| 欧美韩日一区二区三区| 在线不卡的av| 91国在线观看| 国产成人啪午夜精品网站男同| 亚洲国产精品一区二区www在线| 精品国产成人系列| 欧美日韩一卡二卡三卡| www.色综合.com| 国产一二精品视频| 午夜精品123| 亚洲另类在线视频| 国产精品免费人成网站| 精品国产露脸精彩对白| 欧美高清视频一二三区| 一本大道久久精品懂色aⅴ| 国产一区不卡在线| 久久99久国产精品黄毛片色诱| 亚洲午夜电影在线观看| 国产精品理伦片| 欧美国产欧美综合| 久久奇米777| 精品黑人一区二区三区久久| 欧美一区欧美二区| 欧美色网一区二区| 色成人在线视频| 成人免费va视频| 国产成人在线免费观看| 精品一区二区三区欧美| 久久66热偷产精品| 日日夜夜免费精品视频| 亚洲一区二区三区不卡国产欧美| 国产精品久久国产精麻豆99网站| 久久久久久久久久久久久夜| 欧美本精品男人aⅴ天堂| 日韩欧美在线综合网| 日韩精品在线一区二区| 欧美精品一区二区久久婷婷| 精品99999| 国产网红主播福利一区二区| 国产亚洲精品免费| 日本一区二区三区免费乱视频 | 成人sese在线| www.成人网.com| 成人一区二区三区在线观看| 国产激情91久久精品导航| 国产成人亚洲综合a∨猫咪| 国产精品自在欧美一区| 国产在线播放一区| 成人免费高清视频在线观看| 99精品久久只有精品| 欧美亚洲综合网| 欧美久久久影院| 日韩一区二区影院| 久久精品综合网| 最好看的中文字幕久久| 亚洲一区精品在线| 奇米色一区二区| 久久se精品一区二区| 国产成人激情av| 99久久亚洲一区二区三区青草 | 天堂一区二区在线| 日韩电影在线一区| 国产一区二区三区四区五区入口 | 中文字幕一区二区三区色视频 | 国产黄色成人av| 91网上在线视频| 欧美一级精品大片| 一区二区中文视频| 日韩成人精品在线观看| 国产精品一区二区三区网站| 欧美在线观看一区二区| 日韩欧美国产1| 中文字幕国产精品一区二区| 同产精品九九九| 成人小视频免费在线观看| 欧美精品乱人伦久久久久久| 久久精品视频免费观看| 亚洲综合丁香婷婷六月香| 精品一区二区三区视频 | 精品国产制服丝袜高跟| 国产女主播视频一区二区| 亚洲宅男天堂在线观看无病毒| 国产福利91精品一区| 欧美一区二区在线不卡| 亚洲素人一区二区| 国产精品亚洲午夜一区二区三区 | 紧缚捆绑精品一区二区| 色老汉一区二区三区| 欧美国产视频在线| 久久国内精品自在自线400部| 色综合亚洲欧洲| 久久久激情视频| 麻豆精品视频在线| 欧美日韩在线一区二区| 亚洲精品中文在线观看| 国产成人三级在线观看| 26uuu国产电影一区二区| 石原莉奈在线亚洲二区| 日本韩国欧美一区| 国产精品久线观看视频| 久久精品国产一区二区三| 欧美日韩二区三区| 亚洲同性gay激情无套| 成人一区二区三区视频在线观看 | 欧美卡1卡2卡| 中文字幕制服丝袜成人av| 国产美女视频一区| 日韩美女视频在线| 五月天中文字幕一区二区| 色婷婷国产精品| 国产精品高潮呻吟久久| 成人黄色在线看| 国产日产亚洲精品系列| 国产一区二区调教| 精品久久久久久亚洲综合网| 国产一区二区在线观看免费| 337p粉嫩大胆色噜噜噜噜亚洲 | 日韩高清一区二区|