Clarity Javascript SDK



centercenterIntuli?? Clarity Javascript SDK8820090900Intuli?? Clarity Javascript SDKContents TOC \o "1-3" \h \z \u Clarity PAGEREF _Toc531588964 \h 4Getting Started PAGEREF _Toc531588965 \h 4Credentials PAGEREF _Toc531588966 \h 4Methods PAGEREF _Toc531588967 \h 4After PAGEREF _Toc531588968 \h 4Summary: PAGEREF _Toc531588969 \h 4Parameters: PAGEREF _Toc531588970 \h 4Examples: PAGEREF _Toc531588971 \h 4Before PAGEREF _Toc531588972 \h 5Summary: PAGEREF _Toc531588973 \h 5Parameters: PAGEREF _Toc531588974 \h 5Examples: PAGEREF _Toc531588975 \h 5CleanHTML PAGEREF _Toc531588976 \h 5Summary: PAGEREF _Toc531588977 \h 5Parameters: PAGEREF _Toc531588978 \h 5Examples: PAGEREF _Toc531588979 \h 5HTMLDecode PAGEREF _Toc531588980 \h 5Summary: PAGEREF _Toc531588981 \h 5Parameters: PAGEREF _Toc531588982 \h 6Examples: PAGEREF _Toc531588983 \h 6HTMLEncode PAGEREF _Toc531588984 \h 6Summary: PAGEREF _Toc531588985 \h 6Parameters: PAGEREF _Toc531588986 \h 6Examples: PAGEREF _Toc531588987 \h 6RegexChunk PAGEREF _Toc531588988 \h 6Summary: PAGEREF _Toc531588989 \h 6Parameters: PAGEREF _Toc531588990 \h 6Examples: PAGEREF _Toc531588991 \h 6RegexCount PAGEREF _Toc531588992 \h 7Summary: PAGEREF _Toc531588993 \h 7Parameters: PAGEREF _Toc531588994 \h 7Examples: PAGEREF _Toc531588995 \h 7RegexEscape PAGEREF _Toc531588996 \h 7Summary: PAGEREF _Toc531588997 \h 7Parameters: PAGEREF _Toc531588998 \h 7Examples: PAGEREF _Toc531588999 \h 7RegexExtract PAGEREF _Toc531589000 \h 7Summary: PAGEREF _Toc531589001 \h 7Parameters: PAGEREF _Toc531589002 \h 8Examples: PAGEREF _Toc531589003 \h 8RegexExtractAll PAGEREF _Toc531589004 \h 8Summary: PAGEREF _Toc531589005 \h 8Parameters: PAGEREF _Toc531589006 \h 8Examples: PAGEREF _Toc531589007 \h 9RegexExtractEach PAGEREF _Toc531589008 \h 9Summary: PAGEREF _Toc531589009 \h 9Parameters: PAGEREF _Toc531589010 \h 9Examples: PAGEREF _Toc531589011 \h 9RegexExtractInt PAGEREF _Toc531589012 \h 9Summary: PAGEREF _Toc531589013 \h 10Parameters: PAGEREF _Toc531589014 \h 10Examples: PAGEREF _Toc531589015 \h 10RegexIsMatch PAGEREF _Toc531589016 \h 10Summary: PAGEREF _Toc531589017 \h 10Parameters: PAGEREF _Toc531589018 \h 10Examples: PAGEREF _Toc531589019 \h 10RegexReplace PAGEREF _Toc531589020 \h 10Summary: PAGEREF _Toc531589021 \h 10Parameters: PAGEREF _Toc531589022 \h 11Examples: PAGEREF _Toc531589023 \h 11RemoveDuplicateWhitespaceChars PAGEREF _Toc531589024 \h 11Summary: PAGEREF _Toc531589025 \h 11Parameters: PAGEREF _Toc531589026 \h 11Examples: PAGEREF _Toc531589027 \h 11RemoveExtraWhitespace PAGEREF _Toc531589028 \h 11Summary: PAGEREF _Toc531589029 \h 11Parameters: PAGEREF _Toc531589030 \h 12Examples: PAGEREF _Toc531589031 \h 12RemoveWhitespace PAGEREF _Toc531589032 \h 12Summary: PAGEREF _Toc531589033 \h 12Parameters: PAGEREF _Toc531589034 \h 12Examples: PAGEREF _Toc531589035 \h 12SHA PAGEREF _Toc531589036 \h 12Summary: PAGEREF _Toc531589037 \h 12Parameters: PAGEREF _Toc531589038 \h 12Examples: PAGEREF _Toc531589039 \h 12MD5 PAGEREF _Toc531589040 \h 12Summary: PAGEREF _Toc531589041 \h 12Parameters: PAGEREF _Toc531589042 \h 13Examples: PAGEREF _Toc531589043 \h 13CleanName PAGEREF _Toc531589044 \h 13Summary: PAGEREF _Toc531589045 \h 13Parameters: PAGEREF _Toc531589046 \h 13Examples: PAGEREF _Toc531589047 \h 13BestMatch PAGEREF _Toc531589048 \h 13Summary: PAGEREF _Toc531589049 \h 13Parameters: PAGEREF _Toc531589050 \h 14Examples: PAGEREF _Toc531589051 \h 14ClarityClarity is a serverless, cloud hosted collection of data cleaning and extraction tools. Along with the developer portal documentation, we also have Clarity SDK documentation for Python, .NET, and JavaScript. These are used for easy API calls, and better integration with your internal systems.Getting StartedThe JavaScript SDK only allows for asynchronous operations, and therefore all functions require a callback method. Before calling any methods within the SDK, you will first need to set your API key.CredentialsSummary:This string value must be set to your registered API key. This will need to be done any time the Javascript Clarity SDK is instantiated.Example:Clarity.Credentials.APIKey = “your api key”;MethodsAfterSummary:The After function will return all text in a string which appears after the supplied regular expression pattern.Parameters:Sourcestring – The string to extract from.RegExPattern – The pattern to use as the position for the beginning of the new string.Optional: ReturnAllonNoMatch – If true, then when the pattern does not match the string, the entire string will be returned. By default, nothing is returned on a no match.Examples:Clarity.After("i like pizza", "like", function(returnString) {console.log(returnString)});Clarity.After("i like pizza", "like", function(returnString) {console.log(returnString)}, true);BeforeSummary:The Before function will return all text in a string which appears before the supplied regular expression pattern.Parameters:Sourcestring – The string to extract from.RegExPattern – The pattern to use as the position for the end of the new string.Optional: ReturnAllonNoMatch – If true, then when the pattern does not match the string, the entire string will be returned. By default, nothing is returned on a no match.Examples:Clarity.Before("i like pizza", "pizza", function(returnString) {console.log(returnString)});Clarity.Before("i like pizza", "like", function(returnString) {console.log(returnString)}, false);CleanHTMLSummary:The CleanHTML function will return a string which has all HTML encodings and tags removed. This can be used to convert an HTML document into a plain text document which will show only the display text and will attempt to preserve spacing. Special characters encoded in the HTML (Ex. &gt;, &amp;, &#146;, etc.) will be converted to their Unicode equivalents.Parameters:HTMLData – The HTML formatted string to convert.Examples:Clarity.CleanHTML(“This removes <sup>superscripts<sup> &amp; other HTML content”, function(returnString) { console.log(returnString)});HTMLDecodeSummary:The HTMLDecode function will return a string which replaces all HTML special characters with their Unicode equivalents. Parameters:Text – The string to decode.Examples:Clarity.HTMLDecode(“2 &plus; 2 = 4”, function(returnString) { console.log(returnString)});HTMLEncodeSummary:The HTMLEncode function will return a string which replaces all reserved HTML characters and extended characters with their HTML Encoded values (Ex. > is converted to &gt;)Parameters:Text – The string to encode.Examples:Clarity.HTMLEncode(“2 > 1”, function(returnString) { console.log(returnString)});RegexChunkSummary:The RegexChunk function returns an array of strings created by splitting the source string into chunks defined by alternating the matching regular expression pattern and the text between the matches.Parameters:SourceString – The string to be broken into chunks.RegExPattern – The regular expression pattern used to identify the break positions of the chunks.Optional: CaseSensitive – If true, the pattern will be case sensitive.Optional: RemoveEmpty – If true, any empty array values will be removed.Examples:Clarity.RegexChunk("I like pizza", "\\s", function(returnString) {console.log(returnString)});Clarity.RegexChunk("I like pizza", "\\s", function(returnString) {console.log(returnString)}, true);Clarity.RegexChunk("I like pizza", "\\s", function(returnString) {console.log(returnString)}, true, false);RegexCountSummary:The RegexCount function returns an integer indicating the number of times the regular expression matches the source string.Parameters:SourceString – The string to be matched.RegExPattern – The regular expression pattern to match.Optional: CaseSensitive – If true, the pattern will be case sensitive.Examples:Clarity.RegexCount("I I I I I", "i", function(returnString) {console.log(returnString)})Clarity.RegexCount("I I I I I", "i", function(returnString) {console.log(returnString)}, true)RegexEscapeSummary:The RegexEscape function returns a string which escapes any special characters for a regular expression pattern. The result is a regular expression which will exactly match the supplied string and will not create any errors.Parameters:SourceString – The regular expression pattern to be escaped.Examples:Clarity.RegexEscape("This will escape any regex characters. Like ?", function(returnString) { console.log(returnString)});RegexExtractSummary:The RegexExtract function returns a string containing the capture of the first instance in the source string which matches the regular expression pattern. If no capture groups are defined in the pattern, then the entire pattern is returned as capture group one.Parameters:SourceString – The string to be matched.RegExPattern – The regular expression pattern to match.Optional: OutputString – If specified the output will be the string and will treat \<number> as back references to capture groups. (Ex. “Test \1” would output “Test “, followed by whatever was captured by the first capture group of the pattern.Optional CaseSensitive – If true, the pattern will be case sensitive.Optional ReverseSearch – If true, the string will be searched for matches starting at the end of the string and working backward.Optional ReturnNothingonPatternFail – If true Nothing will be returned if there is no match, by default an empty string is returned on no match.Examples:Clarity.RegexExtract("This will return the captured string", "this(.*?)string", function(returnString) {console.log(returnString)}); Clarity.RegexExtract("This will return the captured string", "this(.*?)string", function(returnString) {console.log(returnString)}, "\\1");Clarity.RegexExtract("This will return the captured string", "this(.*?)string", function(returnString) {console.log(returnString)}, "\\1", false);Clarity.RegexExtract("This will return the captured string", "this(.*?)string", function(returnString) {console.log(returnString)}, "\\1", false, true);Clarity.RegexExtract("This will return the captured string", "this(.*?)string", function(returnString) {console.log(returnString)}, "\\1", false, true, true);RegexExtractAllSummary:The RegexExtractAll function returns an array of strings containing the capture of each instance in the source string which matches the regular expression pattern. Parameters:SourceString – The string to be matched.RegExPattern – The regular expression pattern to match.Optional: CaseSensitive – If true, the pattern will be case sensitive.Examples:Clarity.RegexExtractAll("This will return all regex matches", "(\\w+)", function(returnString) {console.log(returnString)}); Clarity.RegexExtractAll("This will return all regex matches", "(\\w+)", function(returnString) {console.log(returnString)}, true);RegexExtractEachSummary:The RegexExtractEach function returns an array of strings containing the capture of each capture group from the first match in the source string. Parameters:SourceString – The string to be matched.RegExPattern – The regular expression pattern to match.Optional: CaseSensitive – If true, the pattern will be case sensitive.Optional: ReverseSearch – If true, the string will be searched for matches starting at the end of the string and working backward.Examples:Clarity.RegexExtractEach("Position 1 Mal", "Position\\s(\\d)\\s+(\\w+)", function(returnString) { console.log(returnString)});Clarity.RegexExtractEach("Position 1 Mal", "Position\\s(\\d)\\s+(\\w+)", function(returnString) { console.log(returnString)}, true);Clarity.RegexExtractEach("Position 1 Mal", "Position\\s(\\d)\\s+(\\w+)", function(returnString) { console.log(returnString)}, true, false);Clarity.RegexExtractEach("Position 1 Mal", "Position\\s(\\d)\\s+(\\w+)", function(returnString) { console.log(returnString)}, true, false, false);RegexExtractIntSummary:The RegexExtractInt function returns an integer containing the capture of the first instance in the source string which matches the regular expression pattern. If the captured data is not numeric then a -1 is returned. If no capture groups are defined in the pattern, then the entire pattern is returned as capture group one.Parameters:SourceString – The string to be matched.RegExPattern – The regular expression pattern to match.OPTIONAL: CaseSensitive – If true, the pattern will be case sensitive.Examples:Clarity.RegexExtractInt("I like 2 pizzas", "like\\s(\\d+)\\spizzas", function(returnString) {console.log(returnString)});Clarity.RegexExtractInt("I like 2 pizzas", "like\\s(\\d+)\\spizzas", function(returnString) {console.log(returnString)}, false);RegexIsMatchSummary:The RegexIsMatch function returns a Boolean indicating if the regular expression pattern matches any part of the source string.Parameters:SourceString – The string to be matched.RegExPattern – The regular expression pattern to match.OPTIONAL: CaseSensitive – If true, the pattern will be case sensitive.Examples:Clarity.RegexIsMatch("This will return true if there is a match", "true", function(returnString) {console.log(returnString)}); Clarity.RegexIsMatch("This will return true if there is a match", "true", function(returnString) {console.log(returnString)}, false);RegexReplaceSummary:The RegexReplace function returns a string with all matches of the RegExPattern replaced with the ReplaceString. The replacement string supports backslash delimited backreferences, so you can include capture group 1 by including \1 in the string.Parameters:SourceString – The string to be matched.RegExPattern – The regular expression pattern to match.ReplaceString – The string representing what to replace each pattern match with.Optional: CaseSensitive – If true, the pattern will be case sensitive.Examples:Clarity.RegexReplace(“This will replace this true, with false”, “true”, “false”, function(returnString) { console.log(returnString)});Clarity.RegexReplace(“This will replace this true, with false”, “true”, “false”, true, function(returnString) { console.log(returnString)});RemoveDuplicateWhitespaceCharsSummary:The RemoveDuplicateWhitespaceChars function returns a string where the whitespace has been cleaned up to remove duplicate spacing. Newlines, tabs, and spaces are preserved, but are only included once per chunk of whitespace. The result is that large spaces are removed and replaced with single whitespace characters.Parameters:Text – The string to be cleaned.Examples:Clarity.RemoveDuplicateWhiteSpaceChars (“This will remove extra spacing”, function(returnString) { console.log(returnString)});RemoveExtraWhitespaceSummary:The RemoveExtraWhitespace function returns a string where all whitespace areas are replaced with single spaces. This removes any whitespace gaps, newlines, and tabs from the string while preserving a single space for each whitespace area.Parameters:Text – The string to be cleaned.Examples:Clarity.RemoveExtraWhitespace(“This will remove extra spacing”, function(returnString) { console.log(returnString)});RemoveWhitespaceSummary:The RemoveWhitespace function returns a string where all whitespace areas are removed.Parameters:Text – The string to be cleaned.Examples:Clarity.RemoveWhitespace(“This removes all whitespace extra spacing”, function(returnString) { console.log(returnString)}); SHASummary:The SHA function returns a string which is a SHA512 hash of the input string. This can be used as a unique identifier for a string because two matching strings are extremely unlikely to have matching SHA hash valuesParameters:StringtoConvert – The string to hash.Examples:Clarity.SHA(“An example article title”, function(returnString) { console.log(returnString)}); MD5Summary:The MD5 function returns a string which is an MD5 hash of the supplied string. This can be used to create a unique hash to represent a string value as it is very rare that two, non-identical strings would produce the same MD5 hash.Parameters:StringtoConvert – The string to be hashed.Examples:Clarity.MD5(“An example article title”, function(returnString) { console.log(returnString)}); CleanNameSummary:The CleanName function takes a string containing a person’s name and converts it into a NameEntity object which allows the name parts to be accessed by individual properties. It identifies the parts of the name, even when they are in different formats.Parameters:Name – A string containing the full name to be cleaned.optional: existPrefixes – If false, then it is assumed there are no prefixes (Ex. Dr, Mr, Mrs, etc.)optional: existSuffixes – If false, then it is assumed there are no suffixes (Ex. Jr, Sr, III, etc.)optional: existMiddleNames – If False, then it is assumed there are no middles names, only compound first names or compound last names.Examples:Clarity.CleanName("Dr. Alfred James Von Schmidt III", function(returnString) {console.log(returnString)}); Clarity.CleanName("Dr. Alfred James Von Schmidt III", function(returnString) {console.log(returnString)}, true); Clarity.CleanName("Dr. Alfred James Von Schmidt III", function(returnString) {console.log(returnString)}, true, false); Clarity.CleanName("Dr. Alfred James Von Schmidt III", function(returnString) {console.log(returnString)}, true, false, true); BestMatchSummary:The BestMatch function will return the string from a list of strings which most closely matches the match string, using a Levenstein distance calculation to determine the similarity of each string.Parameters:MatchString – The string to extract from.StringList – The list of strings to compare to the matchstring.Examples:Clarity.BestMatch("ran", ["walk", "run", "running", "jog"], function(returnString) {console.log(returnString)}); ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download