Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
pyLSHash/examples/example_fuzzy_hash.py at main · own-boldsbrain/pyLSHash · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
own-boldsbrain
pyLSHash
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
pyLSHash
/
examples
/
example_fuzzy_hash.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
60 lines (43 loc) · 2.23 KB
main
Breadcrumbs
pyLSHash
/
examples
/
example_fuzzy_hash.py
Copy path
Top
File metadata and controls
Code
Blame
60 lines (43 loc) · 2.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from
pyLSHash
import
FuzzyHash
fuzzy_hash
=
FuzzyHash
()
sentence
=
'''
近期,有一部热播硬核电视剧引发全网关注。与其他硬核电视剧不同的是,这部电视剧真的硬“核”,含“核”量高达100%。
这就是《许你万家灯火》——首部全景反映我国核电工业发展历程的电视剧。
《许你万家灯火》极具年代感,这是因为取景地之一是中国核动力的发源地——九〇九基地。
中国第一代核潜艇研发实验基地
也是中国核动力研究设计院的前身
剧组在基地里面内置景,1:1复刻了主要场景十余个,
包括第一座陆上模式堆主控室、核电大院、核电办公楼、核电家属楼、零号点、医院、图书馆、大礼堂等,
高度还原了老一辈核工业人的研发和生活环境。
而《许你万家灯火》的创作题材,便是中国完全自主知识产权的三代核电技术——“华龙一号”。
从核潜艇研发起步的中国核工业
如何实现拥有世界一流核电站的梦想?
'''
hash1
=
fuzzy_hash
.
get_hash
(
sentence
.
encode
(
'utf-8'
))
sentence2
=
"开头 "
+
sentence
.
replace
(
'电视剧'
,
'视频'
)
+
" 结尾"
hash2
=
fuzzy_hash
.
get_hash
(
sentence2
.
encode
(
'utf-8'
))
print
(
hash1
)
print
(
hash2
)
corr
=
fuzzy_hash
.
compare
(
hash1
,
hash2
)
print
(
'corr = {}%'
.
format
(
corr
))
assert
corr
>
80
# %% replace
sim_hash_val1
=
fuzzy_hash
.
get_hash
(
sentence
.
encode
(
'utf-8'
))
words_to_modify
=
[
'纪录片'
,
'电影'
,
'视频'
]
for
word
in
words_to_modify
:
sentence2
=
sentence
.
replace
(
'电视剧'
,
word
)
sim_hash_val2
=
fuzzy_hash
.
get_hash
(
sentence2
.
encode
(
'utf-8'
))
corr
=
fuzzy_hash
.
compare
(
sim_hash_val1
,
sim_hash_val2
)
assert
corr
>
85
# %% insert
for
insert_idx
in
range
(
0
,
len
(
sentence
)):
sentence2
=
sentence
[:
insert_idx
]
+
"随机插入"
+
sentence
[
insert_idx
:]
sim_hash_val2
=
fuzzy_hash
.
get_hash
(
sentence2
.
encode
(
'utf-8'
))
corr
=
fuzzy_hash
.
compare
(
sim_hash_val1
,
sim_hash_val2
)
assert
corr
>
95
# %% delete
for
insert_idx
in
range
(
0
,
len
(
sentence
)
-
5
):
sentence2
=
sentence
[:
insert_idx
]
+
sentence
[
insert_idx
+
5
:]
sim_hash_val2
=
fuzzy_hash
.
get_hash
(
sentence2
.
encode
(
'utf-8'
))
corr
=
fuzzy_hash
.
compare
(
sim_hash_val1
,
sim_hash_val2
)
assert
corr
>
95
You can’t perform that action at this time.