-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path相似性.r
22 lines (11 loc) · 1.12 KB
/
相似性.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
library(RecordLinkage)
# 计算字符串相似性
levenshteinSim("Nucleoside triphosphate", "2,5-Diaminopyrimidine nucleoside triphosphate")
library(stringdist)
stringsim("hello", "hallo", method = "lv")
# 返回值:0.8(Levenshtein相似性)
stringdist::stringsim("Nucleoside triphosphate", "2,5-Diaminopyrimidine nucleoside triphosphate", method = "cosine")
stringdist::stringsim(a=c("Nucleoside triphosphate"), b=c("2,5-Diaminopyrimidine nucleoside triphosphate","(hydroxy)phosphoryl)oxy](hydroxy)phosphoryl}oxy)phosphonic acid","N-(2,5-diamino-6-oxo-1,6-dihydropyrimidin-4-yl)-5-O-(hydroxy{[hydroxy(phosphonooxy)phosphoryl]oxy}phosphoryl)-beta-D-ribofuranosylamine"), method = "cosine")
b=c("2,5-Diaminopyrimidine nucleoside triphosphate","(hydroxy)phosphoryl)oxy](hydroxy)phosphoryl}oxy)phosphonic acid","N-(2,5-diamino-6-oxo-1,6-dihydropyrimidin-4-yl)-5-O-(hydroxy{[hydroxy(phosphonooxy)phosphoryl]oxy}phosphoryl)-beta-D-ribofuranosylamine")
stringdist::stringsim(a=c("Nucleoside triphosphate"), b=paste(b,collapse = ";"), method = "cosine")
stringdist::stringsim(a=c("Nucleoside triphosphate"), b=b, method = "cosine")