Description Usage Details Methods Methods References Examples
Utility functions
Utility functions
1 | # init <- FuzzUtils$new()
|
the decoding parameter is useful in case of non-ascii character strings. If this parameter is not NULL then the force_ascii parameter (if applicable) is internally set to FALSE. Decoding applies only to python 2 configurations, as in python 3 character strings are decoded to unicode by default.
the Full_process processes a string by : 1. removing all but letters and numbers, 2. trim whitespace, 3. force to lower case and 4. if force_ascii == TRUE, force convert to ascii
the INTR method returns a correctly rounded integer
the Make_type_consistent method converts both objects if they aren't either both string or unicode instances to unicode
the Asciidammit performs ascii dammit using the following expression bad_chars = str("").join([chr(i) for i in range(128, 256)]). Applies to any kind of R data type.
the Asciionly method returns the same result as the Asciidammit method but for character strings using the python .translate() function.
the Validate_string method checks that the input has length and that length is greater than 0
Some of the utils functions are used as secondary methods in the FuzzExtract class. See the examples of the FuzzExtract class for more details.
FuzzUtils$new()
--------------
Full_process(string = NULL, force_ascii = TRUE, decoding = NULL)
--------------
INTR(n = 2.0)
--------------
Make_type_consistent(string1 = NULL, string2 = NULL)
--------------
Asciidammit(input = NULL)
--------------
Asciionly(string = NULL)
--------------
Validate_string(string = NULL)
new()
FuzzUtils$new()
Full_process()
FuzzUtils$Full_process(string = NULL, force_ascii = TRUE, decoding = NULL)
string
a character string.
force_ascii
allow only ASCII characters (force convert to ascii)
decoding
either NULL or a character string. If not NULL then the decoding parameter takes one of the standard python encodings (such as 'utf-8'). See the details and references link for more information (in this class it applies only to the Full_process function)
INTR()
FuzzUtils$INTR(n = 2)
n
a float number
Make_type_consistent()
FuzzUtils$Make_type_consistent(string1 = NULL, string2 = NULL)
string1
a character string.
string2
a character string.
Asciidammit()
FuzzUtils$Asciidammit(input = NULL)
input
any kind of data type (applies to the Asciidammit method)
Asciionly()
FuzzUtils$Asciionly(string = NULL)
string
a character string.
Validate_string()
FuzzUtils$Validate_string(string = NULL)
string
a character string.
clone()
The objects of this class are cloneable with this method.
FuzzUtils$clone(deep = FALSE)
deep
Whether to make a deep clone.
https://github.com/seatgeek/fuzzywuzzy/blob/master/fuzzywuzzy/utils.py, https://docs.python.org/3/library/codecs.html#standard-encodings
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 | try({
if (reticulate::py_available(initialize = FALSE)) {
if (check_availability()) {
library(fuzzywuzzyR)
s1 = 'Frodo Baggins'
s2 = 'Bilbo Baggin'
init = FuzzUtils$new()
init$Full_process(string = s1, force_ascii = TRUE)
init$INTR(n = 2.0)
init$Make_type_consistent(string1 = s1, string2 = s2)
#------------------------------------
# 'Asciidammit' with character string
#------------------------------------
init$Asciidammit(input = s1)
#----------------------------------------------------------------
# 'Asciidammit' with data.frame(123) [ or any kind of data type ]
#----------------------------------------------------------------
init$Asciidammit(input = data.frame(123))
init$Asciionly(string = s1)
init$Validate_string(string = s2)
}
}
}, silent=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.