-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3e6ef5
commit e0ff7d7
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Distances between lists of integer vectors. Note the postfix 'L' to force | ||
# integer storage. The shorter argument is recycled over (\code{a}) | ||
a <- list(c(102L, 107L)) # fu | ||
b <- list(c(102L,111L,111L),c(102L,111L,111L)) # foo, fo | ||
seq_dist(a,b) | ||
|
||
# translate strings to a list of integer sequences | ||
a <- lapply(c("foo","bar","baz"),utf8ToInt) | ||
seq_distmatrix(a) | ||
|
||
# Note how missing values are treated. NA's as part of the sequence are treated | ||
# as an integer (the representation of \code{NA_integer_}). | ||
a <- list(NA_integer_,c(102L, 107L)) | ||
b <- list(c(102L,111L,111L),c(102L,111L,NA_integer_)) | ||
seq_dist(a,b) | ||
|
||
\dontrun{ | ||
# Distance between sentences based on word order. Note: words must match exactly or they | ||
# are treated as completely different. | ||
# | ||
# For this example you need to have the 'hashr' package installed. | ||
a <- "Mary had a little lamb" | ||
a.words <- strsplit(a,"[[:blank:]]+") | ||
a.int <- hashr::hash(a.words) | ||
b <- c("a little lamb had Mary", | ||
"had Mary a little lamb") | ||
b.int <- hashr::hash(strsplit(b,"[[:blank:]]+")) | ||
seq_dist(a.int,b.int) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
L1 <- list(1:3,2:4) | ||
L2 <- list(1:3) | ||
seq_sim(L1,L2,method="osa") | ||
|
||
|