hash

how to use boost::unordered_map

这一生的挚爱 提交于 2020-01-03 02:26:12
问题 for my application, i need to use a hash map, so i have written a test program in which i store some instances of a baseclass in a boost::unordered_map. but i want to reach the instances by calling special functions which return a derived class of the base and i use those functions' parameters for hash key of unordered_map. if no class is found with certain parameters then a class is generated and stored in map. the purpose of the program may not be clear but here is the code. #include <boost

以图搜图技术与simhash算法.md

旧时模样 提交于 2020-01-02 23:21:37
背景 以图搜图是很有颠覆力的应用,俗话说 一图胜千言 不同于文本搜索的匹配模式,以图搜图要对搜索的信息源进行处理,抽取特征信息。在网易存证系统的开发过程中调研了用于以图搜图的 simhash 算法,并设想在内容系统建设完善后可以用于诸多的场景,比如: 商业图片侵权自动取证 肖像内容的识别 家庭照片按场景自动分类 图片指纹比较 simhash算法 阮一峰博客 相似图片搜索的原理 压缩大小 压缩颜色 计算平均灰度值 每个像素和平均值比较,大的为1;小的为0, 进一步向量化 得出向量,就是图片指纹, 计算汉明距离 hamming distance 如上过程的java实现 通过如上粗粒度的算法分析,可知simhash和普通hash算法有较大不同;普通hash算法是对字节流无差别的处理,但是simhash首先会对信息抽取特征值,然后计算汉明距离,最后这步是关键,度量了两个特征量的相似性,让我们有可能在抓取了两张图片的关键特征的基础上,比较其相似性。 动手实验 普通hash是差一个空格,也相差极大,比如如下(差别就是一个是 喊 ,一个是 叫 ): vincent@vincent-B250M-DS3H:~$ cat > 1.txt 你妈妈喊你回家吃饭,回家罗回家罗 vincent@vincent-B250M-DS3H:~$ cat > 2.txt 你妈妈叫你回家吃饭,回家罗回家罗 然后,cat

How to push hash into array of hash in php?

我是研究僧i 提交于 2020-01-02 23:11:30
问题 Like array_push() where we can push an element in to array. I want to push an hash [name,url] in to an array of hash. 回答1: ifif i understand your problem, you want to retrieve hash value from a url then use parse_url with PHP_URL_FRAGMENT argument $url = 'http://username:password@hostname/path?arg=value#anchor'; print_r(parse_url($url)); echo parse_url($url, PHP_URL_FRAGMENT); will return [fragment] => anchor Reference 回答2: If you're referring to associative arrays where the key is user

python 之常用模块

戏子无情 提交于 2020-01-02 22:45:48
模块(module): 模块实质是一个python文件,也就是把python代码写到模块里面。 模块分类: 标准库:python内置 开源模块:第三方 自定义模块:自己写 一、os , sys 模块 import os, sys print(os.getcwd()) #获取当前目录 os.chmod("/usr/share", 7) #给/usr/share目录添加权限 print(os.curdir) #当前目录 print(os.pardir) #父目录 print(os.makedirs("/usr/local/mysql")) #递归创建目录,父目录不存在时创建目录 print(os.removedirs("/usr/local/mysql")) #递归删除空目录 print(os.mkdir("new")) #创建文件夹 os.rename("old", "new") #重命名 print(os.path.join("/root",'mysql','rack.sql')) #拼接成一个路径 print(os.path.split("/usr/mysql/123.txt")) #分割路径和文件名 print(os.sep) #当前操作系统的路径分隔符 print(os.linesep) #当前操作系统的换行符 print(os.pathsep)

Python进阶--常用模块

為{幸葍}努か 提交于 2020-01-02 22:44:57
一、模块、包 什么是模块? 模块实质上就是一个python文件,它是用来组织代码的,意思就是说把python代码写到里面,文件名就是模块的名称,test.py test就是模块名称。 什么是包? 包,package本质就是一个文件夹,和文件夹不一样的是它有一个__init__.py文件,包是从逻辑上来组织模块的,也就是说它是用来存放模块的,如果你想导入其他目录下的模块,那么这个目录必须是一个包才可以导入。 导入模块 import module #导入模块 from module import * #导入该模块中的所有方法,慎用 from module import fun as xx_fun #导入指定的方法,然后起别名 from module import fun1,fun2,fun3 #导入模块下的多个方法 import module,实际上就是把该模块的代码赋值给模块名,也就是module.py里面所有的代码,赋值给了module这个变量,如果是from module import fun,就是把module打开,把module里面的fun方法拿过来使用 导入模块的本质,就是把python文件拿过来执行一次。 使用包中的模块需要在__init__.py文件中from . import xxx 模块分类: 标准库:python内置的 开源模块:第三方 自定义模块:自己写的 二

Why doesn't my Perl variable have the right value outside the if() block?

我怕爱的太早我们不能终老 提交于 2020-01-02 19:19:36
问题 I have a hash, where the keys and values are from matches in a regular expression. I'm having difficulty extracting the values given the keys. In the interest of brevity and honing in on the problem, my first version of this post I attempted to strip down my program to only the relevant parts, but it wasn't enough, so here's more. Variable and file names have been modified, but the syntax is true. Though the specific regular expressions are irrelevant, I have included them on request. use

Hash function that hashes similar strings in the same bucket

拜拜、爱过 提交于 2020-01-02 14:12:02
问题 I'm searching for a "bad" hash function: I'd like to hash strings and put similar strings in one bucket. Can you give me a hint where to start my research? Some methods or algorithm names... 回答1: Your problem is not an easy one. Two ideas: This solution might be overly complicated but you could try a Fourier transform. Treat your input text as a series of samples of a function and then run a Fourier transform to convert your input to the frequency domain. The low frequency part is the general

Hash function that hashes similar strings in the same bucket

徘徊边缘 提交于 2020-01-02 14:11:26
问题 I'm searching for a "bad" hash function: I'd like to hash strings and put similar strings in one bucket. Can you give me a hint where to start my research? Some methods or algorithm names... 回答1: Your problem is not an easy one. Two ideas: This solution might be overly complicated but you could try a Fourier transform. Treat your input text as a series of samples of a function and then run a Fourier transform to convert your input to the frequency domain. The low frequency part is the general

HashSet - ensuring the earlier object persistence

a 夏天 提交于 2020-01-02 10:03:31
问题 I have to use a HashSet where a lot of duplicate value may be inserted. But I want to preserve the earlier data inserted in the hash when a later insertion makes the duplicate. To examine this I have write the following code and insert many duplicate value, but it doesn't satisfy me. Please see the code below - import java.util.HashSet; import java.util.Set; public class SetTest { private static Set<Student> studentSet = new HashSet<Student>(); private static Student s1, s2, s3, s4, s5, s6,

HashSet - ensuring the earlier object persistence

南笙酒味 提交于 2020-01-02 10:03:19
问题 I have to use a HashSet where a lot of duplicate value may be inserted. But I want to preserve the earlier data inserted in the hash when a later insertion makes the duplicate. To examine this I have write the following code and insert many duplicate value, but it doesn't satisfy me. Please see the code below - import java.util.HashSet; import java.util.Set; public class SetTest { private static Set<Student> studentSet = new HashSet<Student>(); private static Student s1, s2, s3, s4, s5, s6,