#' @name nepalese_words_to_number
#'
#' @export
#'
#' @title This function allows you to translate to integer numerical words spelled in Nepali.
#'
#' @description This function allows you to translate to integer numerical words spelled in Nepali.
#' Text must be previously cleaned & removed extraneous words or symbols. Below is the list of nepalese
#' words used in this function;
#'
#' \code{"aath", "arba", "athara",
#' "athchaalees", "aththais", "athtis", "baais", "barha", "battis", "bayalees", "bis", "chalees", "char",
#' "chaubis", "chaudha", "chauntis", "chawaalees", "chha", "chhabbis", "chhattis", "chhayaalees", "das",
#' "dui", "eghaara", "ek", "ekchalees", "ekkais", "ekkattis", "hajaar", "karod", "kharaba", "lakh", "nau",
#' "nil", "paanch", "pachas", "pachchis", "padhna", "paintis", "paitaalees", "pandhra", "sacchaalees",
#' "saitis", "sat", "satra", "sattais", "saya", "shankha", "soonya", "sorha", "teis", "terha", "tettis",
#' "tin", "tis", "triyalees", "unanchas", "unantis", "unnais", "unnanchaalis"}
#'
#' @param x x is an input string
#'
#' @return An integer value
#'
#' @author Som Bohora
#'
#' @examples
#'
#'x = "ek karod paanch hajaar paanch saya paanch" # 10005505
#'nepalese_words_to_number(x)
nepalese_words_to_number <- function(x) {
x <- gsub("soonya", "+0" , x , ignore.case = TRUE)
x <- gsub("ek", "+1" , x , ignore.case = TRUE)
x <- gsub("dui", "+2" , x , ignore.case = TRUE)
x <- gsub("tin", "+3" , x , ignore.case = TRUE)
x <- gsub("char", "+4" , x , ignore.case = TRUE)
x <- gsub("paanch", "+5" , x , ignore.case = TRUE)
x <- gsub("chha", "+6" , x , ignore.case = TRUE)
x <- gsub("sat", "+7" , x , ignore.case = TRUE)
x <- gsub("aath", "+8" , x , ignore.case = TRUE)
x <- gsub("nau", "+9" , x , ignore.case = TRUE)
x <- gsub("das", "+10" , x , ignore.case = TRUE)
x <- gsub("eghaara", "+11" , x , ignore.case = TRUE)
x <- gsub("barha", "+12" , x , ignore.case = TRUE)
x <- gsub("terha", "+13" , x , ignore.case = TRUE)
x <- gsub("chaudha", "+14" , x , ignore.case = TRUE)
x <- gsub("pandhra", "+15" , x , ignore.case = TRUE)
x <- gsub("sorha", "+16" , x , ignore.case = TRUE)
x <- gsub("satra", "+17" , x , ignore.case = TRUE)
x <- gsub("athara", "+18" , x , ignore.case = TRUE)
x <- gsub("unnais", "+19" , x , ignore.case = TRUE)
x <- gsub("bis", "+20" , x , ignore.case = TRUE)
x <- gsub("ekkais", "+21" , x , ignore.case = TRUE)
x <- gsub("baais", "+22" , x , ignore.case = TRUE)
x <- gsub("teis", "+23" , x , ignore.case = TRUE)
x <- gsub("chaubis", "+24" , x , ignore.case = TRUE)
x <- gsub("pachchis", "+25" , x , ignore.case = TRUE)
x <- gsub("chhabbis", "+26" , x , ignore.case = TRUE)
x <- gsub("sattais", "+27" , x , ignore.case = TRUE)
x <- gsub("aththais", "+28" , x , ignore.case = TRUE)
x <- gsub("unantis", "+29" , x , ignore.case = TRUE)
x <- gsub("tis", "+30" , x , ignore.case = TRUE)
x <- gsub("ekkattis", "+31" , x , ignore.case = TRUE)
x <- gsub("battis", "+32" , x , ignore.case = TRUE)
x <- gsub("tettis", "+33" , x , ignore.case = TRUE)
x <- gsub("chauntis", "+34" , x , ignore.case = TRUE)
x <- gsub("paintis", "+35" , x , ignore.case = TRUE)
x <- gsub("chhattis", "+36" , x , ignore.case = TRUE)
x <- gsub("saitis", "+37" , x , ignore.case = TRUE)
x <- gsub("athtis", "+38" , x , ignore.case = TRUE)
x <- gsub("unnanchaalis", "+39" , x , ignore.case = TRUE)
x <- gsub("chalees", "+40" , x , ignore.case = TRUE)
x <- gsub("ekchalees", "+41" , x , ignore.case = TRUE)
x <- gsub("bayalees", "+42" , x , ignore.case = TRUE)
x <- gsub("triyalees", "+43" , x , ignore.case = TRUE)
x <- gsub("chawaalees", "+44" , x , ignore.case = TRUE)
x <- gsub("paitaalees", "+45" , x , ignore.case = TRUE)
x <- gsub("chhayaalees", "+46" , x , ignore.case = TRUE)
x <- gsub("sacchaalees", "+47" , x , ignore.case = TRUE)
x <- gsub("athchaalees", "+48" , x , ignore.case = TRUE)
x <- gsub("unanchas", "+49" , x , ignore.case = TRUE)
x <- gsub("pachas", "+50" , x , ignore.case = TRUE)
# x <- gsub("ekaaunna|", "+51" , x , ignore.case = TRUE)
# x <- gsub("baaunna|", "+52" , x , ignore.case = TRUE)
# x <- gsub("tripanna|", "+53" , x , ignore.case = TRUE)
# x <- gsub("chaunna|", "+54" , x , ignore.case = TRUE)
# x <- gsub("pachpanna|", "+55" , x , ignore.case = TRUE)
# x <- gsub("chhapanna|", "+56" , x , ignore.case = TRUE)
# x <- gsub("santaunna|", "+57" , x , ignore.case = TRUE)
# x <- gsub("anthauna|", "+58" , x , ignore.case = TRUE)
# x <- gsub("unansathee|", "+59" , x , ignore.case = TRUE)
# x <- gsub("sathee|", "+60" , x , ignore.case = TRUE)
# x <- gsub("eksatthee|", "+61" , x , ignore.case = TRUE)
# x <- gsub("baisathee|", "+62" , x , ignore.case = TRUE)
# x <- gsub("trisathee|", "+63" , x , ignore.case = TRUE)
# x <- gsub("chausathee|", "+64" , x , ignore.case = TRUE)
# x <- gsub("paisathee|", "+65" , x , ignore.case = TRUE)
# x <- gsub("chaisathee|", "+66" , x , ignore.case = TRUE)
# x <- gsub("satsathee|", "+67" , x , ignore.case = TRUE)
# x <- gsub("athsathee|", "+68" , x , ignore.case = TRUE)
# x <- gsub("unansattaree|", "+69" , x , ignore.case = TRUE)
# x <- gsub("sattaree|", "+70" , x , ignore.case = TRUE)
# x <- gsub("ekhattar|", "+71" , x , ignore.case = TRUE)
# x <- gsub("bahattar|", "+72" , x , ignore.case = TRUE)
# x <- gsub("trihattar|", "+73" , x , ignore.case = TRUE)
# x <- gsub("chauhattar|", "+74" , x , ignore.case = TRUE)
# x <- gsub("pachahattar|", "+75" , x , ignore.case = TRUE)
# x <- gsub("chhahattar|", "+76" , x , ignore.case = TRUE)
# x <- gsub("satahattar|", "+77" , x , ignore.case = TRUE)
# x <- gsub("athahattar|", "+78" , x , ignore.case = TRUE)
# x <- gsub("unasee|", "+79" , x , ignore.case = TRUE)
# x <- gsub("asee|", "+80" , x , ignore.case = TRUE)
# x <- gsub("ekasee|", "+81" , x , ignore.case = TRUE)
# x <- gsub("bayasee|", "+82" , x , ignore.case = TRUE)
# x <- gsub("triyasee|", "+83" , x , ignore.case = TRUE)
# x <- gsub("chaurasee|", "+84" , x , ignore.case = TRUE)
# x <- gsub("pachasee|", "+85" , x , ignore.case = TRUE)
# x <- gsub("chhayasee|", "+86" , x , ignore.case = TRUE)
# x <- gsub("satasee|", "+87" , x , ignore.case = TRUE)
# x <- gsub("athasee|", "+88" , x , ignore.case = TRUE)
# x <- gsub("unannabbe|", "+89" , x , ignore.case = TRUE)
# x <- gsub("nabbe|", "+90" , x , ignore.case = TRUE)
# x <- gsub("ekanabbe|", "+91" , x , ignore.case = TRUE)
# x <- gsub("bayanabbe|", "+92" , x , ignore.case = TRUE)
# x <- gsub("triyanabbe|", "+93" , x , ignore.case = TRUE)
# x <- gsub("chauranabbe|", "+94" , x , ignore.case = TRUE)
# x <- gsub("paanchanabbe|", "+95" , x , ignore.case = TRUE)
# x <- gsub("chhyanabbe|", "+96" , x , ignore.case = TRUE)
# x <- gsub("santanabbe|", "+97" , x , ignore.case = TRUE)
# x <- gsub("anthanabbe|", "+98" , x , ignore.case = TRUE)
# x <- gsub("unansaya|", "+99" , x , ignore.case = TRUE)
x <- gsub("saya", ")*(100)+(0", x , ignore.case = TRUE)
# x <- gsub("dui saya", "+200", x , ignore.case = TRUE)
# x <- gsub("tin saya", "+300", x , ignore.case = TRUE)
# x <- gsub("char saya", "+400", x , ignore.case = TRUE)
# x <- gsub("paanch saya", "+500", x , ignore.case = TRUE)
# x <- gsub("chha saya", "+600", x , ignore.case = TRUE)
# x <- gsub("sat saya", "+700", x , ignore.case = TRUE)
# x <- gsub("aath saya", "+800", x , ignore.case = TRUE)
# x <- gsub("nau saya", "+900", x , ignore.case = TRUE)
x <- gsub("hajaar", ")*(1000)+(0", x , ignore.case = TRUE)
# x <- gsub("dui hajaar", ")*(2000)+(0", x , ignore.case = TRUE)
# x <- gsub("tin hajaar", ")*(3000)+(0", x , ignore.case = TRUE)
# x <- gsub("char hajaar", ")*(4000)+(0", x , ignore.case = TRUE)
# x <- gsub("paanch hajaar", ")*(5000)+(0", x , ignore.case = TRUE)
# x <- gsub("chha hajaar", ")*(6000)+(0", x , ignore.case = TRUE)
# x <- gsub("sat hajaar", ")*(7000)+(0", x , ignore.case = TRUE)
# x <- gsub("aath hajaar", ")*(8000)+(0", x , ignore.case = TRUE)
# x <- gsub("nau hajaar", ")*(9000)+(0", x , ignore.case = TRUE)
# x <- gsub("das hajaar", ")*(10000)+(0", x , ignore.case = TRUE)
# x <- gsub("bis hajaar", ")*(20000)+(0", x , ignore.case = TRUE)
# x <- gsub("tis hajaar", ")*(30000)+(0", x , ignore.case = TRUE)
# x <- gsub("chalis hajaar", ")*(40000)+(0", x , ignore.case = TRUE)
# x <- gsub("pachas hajaar", ")*(50000)+(0", x , ignore.case = TRUE)
# x <- gsub("sathi hajaar", ")*(60000)+(0", x , ignore.case = TRUE)
# x <- gsub("sattari hajaar", ")*(70000)+(0", x , ignore.case = TRUE)
# x <- gsub("asi hajaar", ")*(80000)+(0", x , ignore.case = TRUE)
# x <- gsub("nabbe hajaar", ")*(90000)+(0", x , ignore.case = TRUE)
x <- gsub("lakh", ")*(100000)+(0", x , ignore.case = TRUE)
# x <- gsub("das lakh", ")*(1000000)+(0", x , ignore.case = TRUE)
x <- gsub("karod", ")*(10000000)+(0", x , ignore.case = TRUE)
x <- gsub("arba", ")*(1000000000)+(0", x , ignore.case = TRUE)
x <- gsub("kharaba", ")*(100000000000)+(0", x , ignore.case = TRUE)
x <- gsub("nil", ")*(10000000000000)+(0", x , ignore.case = TRUE)
x <- gsub("padhna", ")*(1000000000000000)+(0", x , ignore.case = TRUE)
x <- gsub("shankha", ")*(100000000000000000)+(0", x , ignore.case = TRUE)
x <- gsub("Y", "", x , ignore.case = T)
x <- gsub(" ", "", x , ignore.case = T)
x <- gsub("^", "(0", x , ignore.case = T)
x <- gsub("$", ")", x , ignore.case = T)
x <- gsub("\\(0\\(", "", x , ignore.case = T )
x <- gsub("\\+\\+", "\\+\\(", x , ignore.case = T )
x <- gsub("\\)\\+\\)", "\\)", x , ignore.case = T )
y = as.integer(eval(parse(text = x)))
if (is.na(y)) {
warning("WARNING: Due to R's limited ability to retain huge integer, the result is displayed in equation form.")
return(list('Parsed value: ' = eval(parse(text = x)), "Actual Equation: " = x))
} else {
return(as.integer(eval(parse(text = x))))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.