R/RcppExports.R

# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#'@title extract_mcc
#'@description extract a mobile carrier code (mcc) from an x_analytics header
#'@details \code{\link{extract_mcc}} grabs a mobile carrier code and associated country code
#'from an x_analytics field, where such a code is present (i.e., requests from Zero)
#'
#'@param x_analytics a vector of x_analytics fields
#'
#'@return a vector of empty strings or MCC codes, depending on if an MCC was found.
#'
#'@export
extract_mcc <- function(x_analytics) {
    .Call('WMUtils_extract_mcc', PACKAGE = 'WMUtils', x_analytics)
}

#'@export
c_ua_parse <- function(agents, yaml_file_loc) {
    .Call('WMUtils_c_ua_parse', PACKAGE = 'WMUtils', agents, yaml_file_loc)
}

#'@title host_handler
#'@details extracts the hostname, TLD and subdomains from a generic URL
#'
#'@description
#'\code{host_handler} is a domain-neutral host extractor for URLs, excluding generic prefixes (http, https, www)
#'and paths/queries.
#'
#'@param urls a character vector of URLs
#'
#'@return a vector of hostnames, or "Unknown" if the hostname was invalid
#'
#'@seealso \code{\link{project_extractor}} for extracting Wikimedia language codes and projects.
#'@export
host_handler <- function(urls) {
    .Call('WMUtils_host_handler', PACKAGE = 'WMUtils', urls)
}

#'@title project_extractor
#'@description extracts language and project from a Wikimedia URL
#'
#'@details \code{project_extractor} takes Wikimedia URLs and extracts the language and project
#'(for example, turning "https://en.wikipedia.org"" into "en.wikipedia"). It can handle both current
#'and historic intermediary domains - zero, mobile, wap - and exclude them consistently.
#'
#'@param urls a vector of URLs
#'
#'@return a vector of language and project names, or "Unknown" if a URL cannot be parsed. In the event
#'that a URL can be parsed but you've been silly enough to pass it a non-Wikimedia URL, it will simply
#'return nonsense.
#'
#'@seealso \code{\link{host_handler}} for extracting hostnames generically.
#'@export
c_project_extractor <- function(urls) {
    .Call('WMUtils_c_project_extractor', PACKAGE = 'WMUtils', urls)
}
wikimedia-research/WMUtils documentation built on May 4, 2019, 5:23 a.m.