首页 文章 精选 留言 我的

精选列表

搜索[压缩算法],共10000篇文章
优秀的个人博客,低调大师

ES 相似度算法设置(续)

Tuning BM25 One of the nice features of BM25 is that, unlike TF/IDF, it has two parameters that allow it to be tuned: k1 This parameter controls how quickly an increase in term frequency results in term-frequency saturation. The default value is 1.2. Lower values result in quicker saturation, and higher values in slower saturation. b This parameter controls how much effect field-length normalization should have.A value of 0.0disables normalization completely, and a value of 1.0normalizes fully. The default is 0.75. The practicalities of tuning BM25 are another matter. The default values fork1andbshould be suitable for most document collections, but the optimal values really depend on the collection. Finding good values for your collection is a matter of adjusting, checking, and adjusting again. The similarity algorithm can be set on a per-field basis.It’s just a matter of specifying the chosen algorithmin the field’s mapping: PUT /my_index { "mappings": { "doc": { "properties": { "title": { "type": "string", "similarity": "BM25" }, "body": { "type": "string", "similarity": "default" } } } } Thetitlefield uses BM25 similarity. Thebodyfield uses the default similarity (seeLucene’s Practical Scoring Function). Currently, it is not possible to change thesimilaritymapping for an existing field. You would need to reindex your data in order to do that. Configuring BM25 Configuring a similarity is muchlike configuring an analyzer. Custom similarities can be specified when creating an index. For instance: PUT /my_index { "settings": { "similarity": { "my_bm25": { "type": "BM25", "b": 0 } } }, "mappings": { "doc": { "properties": { "title": { "type": "string", "similarity": "my_bm25" }, "body": { "type": "string", "similarity": "BM25" } } } } } 参考:https://www.elastic.co/guide/en/elasticsearch/guide/current/changing-similarities.html 本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6472828.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(5)

CStringExportListToExcel(CStringsExcelFile,CListCtrl*pList,CStringstrTitle) { CStringwarningStr; if(pList->GetItemCount()>0){ CDatabasedatabase; CStringsSql; CStringtableName=strTitle; //检索是否安装有Excel驱动"MicrosoftExcelDriver(*.xls)" CStringsDriver; sDriver=GetExcelDriver(); if(sDriver.IsEmpty()) { //没有发现Excel驱动 AfxMessageBox("没有安装Excel!\n请先安装Excel软件才能使用导出功能!"); returnNULL; } ///默认文件名 /*CStringsExcelFile; if(!GetDefaultXlsFileName(sExcelFile)) returnNULL;*/ //创建进行存取的字符串 sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s",sDriver,sExcelFile,sExcelFile); //创建数据库(既Excel表格文件) if(database.OpenEx(sSql,CDatabase::noOdbcDialog)) { //创建表结构 inti; LVCOLUMNcolumnData; CStringcolumnName; intcolumnNum=0; CStringstrH; CStringstrV; sSql=""; strH=""; columnData.mask=LVCF_TEXT; columnData.cchTextMax=100; columnData.pszText=columnName.GetBuffer(100); for(i=0;pList->GetColumn(i,&columnData);i++) { if(i!=0) { sSql=sSql+","; strH=strH+","; } sSql=sSql+""+columnData.pszText+"TEXT"; strH=strH+""+columnData.pszText+""; } columnName.ReleaseBuffer(); columnNum=i; sSql="CREATETABLE"+tableName+"("+sSql+")"; database.ExecuteSQL(sSql); //插入数据项 intnItemIndex; for(nItemIndex=0;nItemIndex<pList->GetItemCount();nItemIndex++){ strV=""; for(i=0;i<columnNum;i++) { if(i!=0) { strV=strV+","; } strV=strV+"'"+pList->GetItemText(nItemIndex,i)+"'"; } sSql="INSERTINTO"+tableName +"("+strH+")" +"VALUES("+strV+")"; database.ExecuteSQL(sSql); } } //关闭数据库 database.Close(); returnsExcelFile; } } 图像处理生成了结果,如果需要保存为报表文件,或者想进一步存入数据库中,Excel都是非常好的选择。在这里集成了vc知识库中提供的代码。版权为 ////////////////////////////////////////////////////////////////////////////// //名称:GetExcelDriver //功能:获取ODBC中Excel驱动 //作者:徐景周(jingzhou_xu@163.net) //组织:未来工作室(FutureStudio) //日期:2002.9.1 ///////////////////////////////////////////////////////////////////////////// 使用的时候,只需要将生成的结果填入 CListCtrl 控件中,而后直接到处就可以。也就是把excel输出的问题变成了向 CListCtrl 控件输出的问题。同时代码中还提供了能够直接写到两个sheet中的方法,可供参考 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(2)

//创建或续写目录下的csv文件,填写“文件位置-分类”对 intwriteCsv(conststring&filename,constVector<pair<string,string>>srcVect,charseparator){ ofstreamfile(filename.c_str(),ofstream::app); if(!file) return0; for(inti=0;i<srcVect.size();i++){ file<<srcVect[i].first<<separator<<srcVect[i].second<<endl; } returnsrcVect.size(); } //读取目录下的csv文件,获得“文件位置-分类”对 vector<pair<string,string>>readCsv(conststring&filename,charseparator){ pair<string,string>apair; stringline,path,classlabel; vector<pair<string,string>>retVect; ifstreamfile(filename.c_str(),ifstream::in); if(!file) returnretVect; while(getline(file,line)){ stringstreamliness(line); getline(liness,path,separator); getline(liness,classlabel); if(!path.empty()&&!classlabel.empty()){ apair.first=path; apair.second=classlabel; retVect.push_back(apair); } } returnretVect; } csv文件是最为简单的带格式文件。这种格式在opencv的人脸识别教程中得到了使用,这里是扣的它的代码。 //获得ini文件中的值 CStringGetInitString(CStringName1,CStringName2){ charc[100]; memset(c,0,100); CStringcsCfgFilePath; GetModuleFileName(NULL,csCfgFilePath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); csCfgFilePath.ReleaseBuffer(); intnPos=csCfgFilePath.ReverseFind('\\'); csCfgFilePath=csCfgFilePath.Left(nPos); csCfgFilePath+="\\Config"; BOOLbr=GetPrivateProfileString(Name1,Name2,"0",c,100,csCfgFilePath); CStringrstr; rstr.Format("%s",c); returnrstr; } //写入ini问价中的值 voidWriteInitString(CStringName1,CStringName2,CStringstrvalue){ CStringcsCfgFilePath; GetModuleFileName(NULL,csCfgFilePath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); csCfgFilePath.ReleaseBuffer(); intnPos=csCfgFilePath.ReverseFind('\\'); csCfgFilePath=csCfgFilePath.Left(nPos); csCfgFilePath+="\\Config"; BOOLbr=WritePrivateProfileString(Name1,Name2,strvalue,csCfgFilePath); if(!br) TRACE("savewrong"); } 这两个函数主要是用来保存和修改配置文件的。通过直接将配置文件写入.ini中达到这个目标。 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(3)

//获得当前目录路径 staticCStringGetLocalPath(){ CStringcsCfgFilePath; GetModuleFileName(NULL,csCfgFilePath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); csCfgFilePath.ReleaseBuffer(); intnPos=csCfgFilePath.ReverseFind('\\'); csCfgFilePath=csCfgFilePath.Left(nPos); returncsCfgFilePath; } //获得.exe路径 staticCStringGetExePath() { CStringstrPath; GetModuleFileName(NULL,strPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH); strPath.ReleaseBuffer(); returnstrPath; } MFC程序涉及的时候存在一个问题,就是某些操作会修改自动"当前路径"的值。这两个函数能够获得当前的路径。 //开机自动运行 staticBOOLSetAutoRun(CStringstrPath,boolflag) { CStringstr; HKEYhRegKey; BOOLbResult; str=_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); if(RegOpenKey(HKEY_LOCAL_MACHINE,str,&hRegKey)!=ERROR_SUCCESS) bResult=FALSE; else { _splitpath(strPath.GetBuffer(0),NULL,NULL,str.GetBufferSetLength(MAX_PATH+1),NULL); strPath.ReleaseBuffer(); str.ReleaseBuffer();//str是键的名字 if(flag){ if(::RegSetValueEx(hRegKey,str,0,REG_SZ,(CONSTBYTE*)strPath.GetBuffer(0),strPath.GetLength())!=ERROR_SUCCESS) bResult=FALSE; else bResult=TRUE; }else{ if(::RegDeleteValue(hRegKey,str)!=ERROR_SUCCESS) bResult=FALSE; else bResult=TRUE; } strPath.ReleaseBuffer(); } returnbResult; } 这个无需更多说明。 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

优秀的个人博客,低调大师

【20160924】GOCVHelper MFC增强算法(4)

//string替换 voidstring_replace(string&strBig,conststring&strsrc,conststring&strdst) { string::size_typepos=0; string::size_typesrclen=strsrc.size(); string::size_typedstlen=strdst.size(); while((pos=strBig.find(strsrc,pos))!=string::npos) { strBig.replace(pos,srclen,strdst); pos+=dstlen; } } 字符串操作一直都是重要的基础操作。在图像处理的过程中,涉及到文件名等变换都需要字符串操作。string_replace中能够成块地换字符。虽然在std中可能已经有相关函数,不过既然我自己的这个用的比较熟悉,就是使用了。 //C++的spilt函数 voidSplitString(conststring&s,vector<string>&v,conststring&c){ std::string::size_typepos1,pos2; pos2=s.find(c); pos1=0; while(std::string::npos!=pos2){ v.push_back(s.substr(pos1,pos2-pos1)); pos1=pos2+c.size(); pos2=s.find(c,pos1); } if(pos1!=s.length()) v.push_back(s.substr(pos1)); } 依然是增强了std中的相关功能,实际使用的时候非常有用。 //!通过文件夹名称获取文件名,不包括后缀 voidgetFileName(conststring&filepath,string&name,string&lastname){ vector<string>spilt_path; SplitString(filepath,spilt_path,"\\"); intspiltsize=spilt_path.size(); stringfilename=""; if(spiltsize!=0){ filename=spilt_path[spiltsize-1]; vector<string>spilt_name; SplitString(filename,spilt_name,"."); intname_size=spilt_name.size(); if(name_size!=0) name=spilt_name[0]; lastname=spilt_name[name_size-1]; } } 前面的函数getfiles能够获得文件的真实路径。那么getFileName能够进一步处理,直接获得图片的名称。很多时候,图片读取了,需要处理一下,这个都是需要的。 来自为知笔记(Wiz) 目前方向:图像拼接融合、图像识别 联系方式:jsxyhelu@foxmail.com

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册