text stringlengths 12 786k |
|---|
let n_noncharacter = ( ns_ucd , " noncharacter " ) |
let n_normalization_correction = ( ns_ucd , " normalization - correction " ) |
let n_normalization_corrections = ( ns_ucd , " normalization - corrections " ) |
let n_provisional_named_sequences = ( ns_ucd , " provisional - named - sequences " ) |
let n_repertoire = ( ns_ucd , " repertoire " ) |
let n_reserved = ( ns_ucd , " reserved " ) |
let n_standardized_variant = ( ns_ucd , " standardized - variant " ) |
let n_standardized_variants = ( ns_ucd , " standardized - variants " ) |
let n_surrogate = ( ns_ucd , " surrogate " ) |
let n_ucd = ( ns_ucd , " ucd " ) |
let add_prop : value Pmap . t -> Xmlm . attribute -> value Pmap . t = let h = Hashtbl . create 500 in let map = Hashtbl . add h in map " AHex " ( Ascii_hex_digit , i_bool ) ; map " Alpha " ( Alphabetic , i_bool ) ; map " Bidi_C " ( Bidi_control , i_bool ) ; map " B... |
let attv n atts = try snd ( List . find ( fun ( en , v ) -> en = ( " " , n ) ) atts ) with | Not_found -> err_miss_att n |
let rec skip_el d = let rec loop d depth = match Xmlm . input d with | ` El_start _ -> loop d ( depth + 1 ) | ` El_end -> if depth = 0 then ( ) else loop d ( depth - 1 ) | s -> loop d depth in loop d 0 |
let p_seq n p_atts d = let rec aux n p_atts d acc = match Xmlm . input d with | ` El_start ( n ' , atts ) when n ' = n -> if Xmlm . input d <> ` El_end then err err_exp_el_end else aux n p_atts d ( ( p_atts atts ) :: acc ) ; | ` El_start _ -> skip_el d ; aux n p_atts d acc | `... |
let p_description d = match ( Xmlm . input d ) with |
let p_name_aliases d = let rec loop d depth acc = match Xmlm . peek d with | ` El_start ( n , atts ) when n = n_name_alias -> ignore ( Xmlm . input d ) ; let alias = ref " " in let atype = ref None in let p_alias_atts = function | ( " " , " alias " ) , v -> alias := v |... |
let p_cp d rep atts g_props = let cp = ref None in let cp_first = ref None in let cp_last = ref None in let add acc ( ( n , v ) as a ) = match n with | ( " " , " cp " ) -> cp := Some ( cp_of_string v ) ; acc | ( " " , " first - cp " ) -> cp_first := Some ( cp_of... |
let p_repertoire d = let eatt t = ( " " , " uax_42_element " ) , t in let rec loop d depth rep g_atts = match Xmlm . input d with | ` El_start ( n , atts ) when n = n_reserved -> loop d ( depth + 1 ) ( p_cp d rep ( eatt " reserved " :: atts ) g_atts ) g_atts | ` El_... |
let p_blocks d = let b_atts atts = ( cp_of_string ( attv " first - cp " atts ) , cp_of_string ( attv " last - cp " atts ) ) , attv " name " atts in p_seq n_block b_atts d |
let p_named_sequences d = let ns_atts atts = attv " name " atts , cps_of_string ( attv " cps " atts ) in p_seq n_named_sequence ns_atts d |
let p_normalization_corrections d = let version_of_string v = try match List . map int_of_string ( split_string v ' . ' ) with | [ v1 ; v2 ; v3 ; ] -> ( v1 , v2 , v3 ) | _ -> failwith " " with Failure _ -> err ( err_att_val v ) in let nc_atts atts = cp_of_string ( attv ... |
let p_standardized_variants d = let when_of_string v = let w s = match s with | " isolate " -> ` Isolate | " initial " -> ` Initial | " medial " -> ` Medial | " final " -> ` Final | s -> err ( err_att_val s ) in List . map w ( split_string v ' ' ) in let sv_atts atts ... |
let p_cjk_radicals d = let cjk_r_atts atts = attv " number " atts , cp_of_string ( attv " radical " atts ) , cp_of_string ( attv " ideograph " atts ) in p_seq n_cjk_radical cjk_r_atts d |
let p_emoji_sources d = let es_atts atts = let opt_int v = if v = " " then None else Some ( cp_of_string v ) in cps_of_string ( attv " unicode " atts ) , opt_int ( attv " docomo " atts ) , opt_int ( attv " kddi " atts ) , opt_int ( attv " softbank " atts ) in p_seq n_em... |
let p_ucd d = let description = ref None in let repertoire = ref None in let blocks = ref None in let named_sequences = ref None in let provisional_named_sequences = ref None in let normalization_corrections = ref None in let standardized_variants = ref None in let cjk_radicals = ref None in let emoji_sources ... |
type src = [ ` Channel of in_channel | ` String of string ] |
let decoder src = let src = match src with ` String s -> ` String ( 0 , s ) | ` Channel _ as s -> s in Xmlm . make_input ~ strip : true src |
let decoded_range d = Xmlm . pos d , Xmlm . pos d |
let decode d = try ignore ( Xmlm . input d ) ; begin match Xmlm . input d with | ` El_start ( n , _ ) when n = n_ucd -> ` Ok ( p_ucd d ) | ` El_start ( n , _ ) -> err ( err_exp_ucd n ) | _ -> assert false end ; with |
type t = [ | ` ASCII | ` Adlam | ` Aegean_Numbers | ` Ahom | ` Alchemical | ` Alphabetic_PF | ` Anatolian_Hieroglyphs | ` Ancient_Greek_Music | ` Ancient_Greek_Numbers | ` Ancient_Symbols | ` Arabic | ` Arabic_Ext_A | ` Arabic_Ext_B | ` Arabic_Math | ` Arabic_PF_A | ` ... |
let pp ppf b = Format . fprintf ppf " % s " begin match b with | ` ASCII -> " ASCII " | ` Adlam -> " Adlam " | ` Aegean_Numbers -> " Aegean_Numbers " | ` Ahom -> " Ahom " | ` Alchemical -> " Alchemical " | ` Alphabetic_PF -> " Alphabetic_PF " | ` Anatolian_Hier... |
module Low = struct let line u = Uucp_tmapbyte . get Uucp_break_data . line_break_map ( Uchar . to_int u ) let line_max = line_max let line_of_int = line_of_byte let grapheme_cluster u = Uucp_tmapbyte . get Uucp_break_data . grapheme_cluster_break_map ( Uchar . to_int u ) let grapheme_cluster_m... |
let line u = Array . unsafe_get Low . line_of_int ( Low . line u ) |
let grapheme_cluster u = Array . unsafe_get Low . grapheme_cluster_of_int ( Low . grapheme_cluster u ) |
let word u = Array . unsafe_get Low . word_of_int ( Low . word u ) |
let sentence u = Array . unsafe_get Low . sentence_of_int ( Low . sentence u ) |
let east_asian_width u = Uucp_rmap . get Uucp_break_data . east_asian_width_map ( Uchar . to_int u ) |
let tty_width_hint = let gc i = Uucp_gc . general_category ( Uchar . unsafe_of_int i ) in let eaw i = east_asian_width ( Uchar . unsafe_of_int i ) in fun u -> match Uchar . to_int u with | 0 -> 0 | u when u <= 0x001F || 0x007F <= u && u <= 0x009F -> - 1 | u when u <= 0x02FF -> 1 ... |
type line = [ ` AI | ` AL | ` B2 | ` BA | ` BB | ` BK | ` CB | ` CJ | ` CL | ` CM | ` CP | ` CR | ` EX | ` EB | ` EM | ` GL | ` H2 | ` H3 | ` HL | ` HY | ` ID | ` IN | ` IS | ` JL | ` JT | ` JV | ` LF | ` NL | ` NS | ` NU | ` ... |
let line_of_byte : line array = [ | ` AI ; ` AL ; ` B2 ; ` BA ; ` BB ; ` BK ; ` CB ; ` CJ ; ` CL ; ` CM ; ` CP ; ` CR ; ` EX ; ` EB ; ` EM ; ` GL ; ` H2 ; ` H3 ; ` HL ; ` HY ; ` ID ; ` IN ; ` IS ; ` JL ; ` JT ; ` ... |
let line_max = Array . length line_of_byte - 1 |
let pp_line ppf v = Format . fprintf ppf " % s " begin match v with | ` AI -> " AI " | ` AL -> " AL " | ` B2 -> " B2 " | ` BA -> " BA " | ` BB -> " BB " | ` BK -> " BK " | ` CB -> " CB " | ` CJ -> " CJ " | ` CL -> " CL " | ` CM -> " C... |
type grapheme_cluster = [ ` CN | ` CR | ` EX | ` EB | ` EBG | ` EM | ` GAZ | ` L | ` LF | ` LV | ` LVT | ` PP | ` RI | ` SM | ` T | ` V | ` XX | ` ZWJ ] |
let grapheme_cluster_of_byte : grapheme_cluster array = [ | ` CN ; ` CR ; ` EX ; ` EB ; ` EBG ; ` EM ; ` GAZ ; ` L ; ` LF ; ` LV ; ` LVT ; ` PP ; ` RI ; ` SM ; ` T ; ` V ; ` XX ; ` ZWJ ] | |
let grapheme_cluster_max = Array . length grapheme_cluster_of_byte - 1 |
let pp_grapheme_cluster ppf v = Format . fprintf ppf " % s " begin match v with | ` CN -> " CN " | ` CR -> " CR " | ` EX -> " EX " | ` EB -> " EB " | ` EBG -> " EBG " | ` EM -> " EM " | ` GAZ -> " GAZ " | ` L -> " L " | ` LF -> " LF " | ` ... |
type word = [ ` CR | ` DQ | ` EX | ` EB | ` EBG | ` EM | ` Extend | ` FO | ` GAZ | ` HL | ` KA | ` LE | ` LF | ` MB | ` ML | ` MN | ` NL | ` NU | ` RI | ` SQ | ` WSegSpace | ` XX | ` ZWJ ] |
let word_of_byte : word array = [ | ` CR ; ` DQ ; ` EX ; ` EB ; ` EBG ; ` EM ; ` Extend ; ` FO ; ` GAZ ; ` HL ; ` KA ; ` LE ; ` LF ; ` MB ; ` ML ; ` MN ; ` NL ; ` NU ; ` RI ; ` SQ ; ` WSegSpace ; ` XX ; ` ZWJ ] | |
let word_max = Array . length word_of_byte - 1 |
let pp_word ppf v = Format . fprintf ppf " % s " begin match v with | ` CR -> " CR " | ` DQ -> " DQ " | ` EX -> " EX " | ` EB -> " EB " | ` EBG -> " EBG " | ` EM -> " EM " | ` Extend -> " Extend " | ` FO -> " FO " | ` GAZ -> " GAZ " | ` ... |
type sentence = [ ` AT | ` CL | ` CR | ` EX | ` FO | ` LE | ` LF | ` LO | ` NU | ` SC | ` SE | ` SP | ` ST | ` UP | ` XX ] |
let sentence_of_byte : sentence array = [ | ` AT ; ` CL ; ` CR ; ` EX ; ` FO ; ` LE ; ` LF ; ` LO ; ` NU ; ` SC ; ` SE ; ` SP ; ` ST ; ` UP ; ` XX ] | |
let sentence_max = Array . length sentence_of_byte - 1 |
let pp_sentence ppf v = Format . fprintf ppf " % s " begin match v with | ` AT -> " AT " | ` CL -> " CL " | ` CR -> " CR " | ` EX -> " EX " | ` FO -> " FO " | ` LE -> " LE " | ` LF -> " LF " | ` LO -> " LO " | ` NU -> " NU " | ` SC -> "... |
type east_asian_width = [ ` A | ` F | ` H | ` N | ` Na | ` W ] |
let pp_east_asian_width ppf v = Format . pp_print_string ppf begin match v with end |
type ' a tree = | Empty | C of int * ' a | Cn of ' a tree * ' a tree * int * ' a |
type ' a t = { default : ' a ; tree : ' a tree } |
let get m cp = let rec loop cp = function | Cn ( l , r , i , v ) -> if cp < i then loop cp l else if cp > i then loop cp r else v | C ( i , v ) -> if cp = i then v else m . default | Empty -> m . default in loop cp m . tree |
let of_sorted_list default l = let rec loop len l = if len = 1 then match l with | ` C ( i , v ) :: r -> C ( i , v ) , r | _ -> assert false else let len_ll = len / 2 in let len_rl = len - len_ll in let ltree , rlist = loop len_ll l in match rlist with | [ ] -> ltree , [ ] ... |
let height m = let rec loop = function | Empty -> 0 | C _ -> 1 | Cn ( l , r , _ , _ ) -> 1 + max ( loop l ) ( loop r ) in loop m . tree |
let word_size v_size m = let rec loop = function | Empty -> 0 | C ( _ , v ) -> 3 + v_size v | Cn ( l , r , _ , v ) -> 5 + loop l + loop r + v_size v in loop m . tree |
let rec dump pp_v ppf m = let open Uucp_fmt in let rec dump_tree ppf = function | Cn ( l , r , i , v ) -> pf ppf " [ @< 4 > Cn ( % a , , @% a , , @ 0x % 04X , , @% a ) ] " @ dump_tree l dump_tree r i pp_v v | C ( i , v ) -> pf ppf " [ @< 3 > C ( 0x % 0... |
let string_X ppf s = Format . pp_open_vbox ppf 1 ; string ppf " " " ; \ for i = 0 to String . length s - 1 do if i mod 16 = 0 && i > 0 then pf ppf " \\@\ n " ; pf ppf " \\ x % 02x " ( Char . code s . [ i ] ) done ; string ppf " " " ; \ Format . pp_close_... |
let string_XN ppf = function " " -> string ppf " snil " | x -> string_X ppf x |
let semi ppf ( ) = string ppf " ; " ; sp ppf ( ) |
let iter i ( ? sep = sp ) pp ppf x = let fst = ref true in i ( fun v -> ( if ! fst then fst := false else sep ppf ( ) ) ; pp ppf v ) x |
let as_array i pp ppf = pf ppf " [ @< 2 [ >|% a ] ] " |@ ( iter i ~ sep : semi pp ) |
let array pp = as_array Array . iter pp |
let array_N pp ppf = function [ ] || -> string ppf " nil " | x -> array pp ppf x |
module R = struct type _ record = | [ ] : unit record | ( ) :: : ( string * ( Format . formatter -> ' a -> unit ) ) * ' b record -> ( ' a -> ' b ) record end |
let record record ppf = let field name pp_v ppf v = pf ppf " [ @< 1 >% s =@ % a ] " @ name pp_v v in let open R in let rec go : type a . ( unit -> unit ) -> a R . record -> a = fun k -> function | [ ] -> pf ppf " [ @< 2 { > % a } ] " @ ( fun _ -> k ) ( ) |... |
let is_dash u = Uucp_tmapbool . get Uucp_func_data . dash_map ( Uchar . to_int u ) |
let is_diacritic u = Uucp_tmapbool . get Uucp_func_data . diacritic_map ( Uchar . to_int u ) |
let is_extender u = Uucp_tmapbool . get Uucp_func_data . extender_map ( Uchar . to_int u ) |
let is_grapheme_base u = Uucp_tmapbool . get Uucp_func_data . grapheme_base_map ( Uchar . to_int u ) |
let is_grapheme_extend u = Uucp_tmapbool . get Uucp_func_data . grapheme_extend_map ( Uchar . to_int u ) |
let is_math u = Uucp_tmapbool . get Uucp_func_data . math_map ( Uchar . to_int u ) |
let is_quotation_mark u = Uucp_tmapbool . get Uucp_func_data . quotation_mark_map ( Uchar . to_int u ) |
let is_soft_dotted u = Uucp_tmapbool . get Uucp_func_data . soft_dotted_map ( Uchar . to_int u ) |
let is_terminal_punctuation u = Uucp_tmapbool . get Uucp_func_data . terminal_punctuation_map ( Uchar . to_int u ) |
let is_regional_indicator u = Uucp_tmapbool . get Uucp_func_data . regional_indicator_map ( Uchar . to_int u ) |
let is_join_control u = Uucp_tmapbool . get Uucp_func_data . join_control_map ( Uchar . to_int u ) |
type t = [ ` Cc | ` Cf | ` Cn | ` Co | ` Cs | ` Ll | ` Lm | ` Lo | ` Lt | ` Lu | ` Mc | ` Me | ` Mn | ` Nd | ` Nl | ` No | ` Pc | ` Pd | ` Pe | ` Pf | ` Pi | ` Po | ` Ps | ` Sc | ` Sk | ` Sm | ` So | ` Zl | ` Zp | ` Zs ] |
let pp ppf c = Format . fprintf ppf " % s " begin match c with | ` Cc -> " Cc " | ` Cf -> " Cf " | ` Cn -> " Cn " | ` Co -> " Co " | ` Cs -> " Cs " | ` Ll -> " Ll " | ` Lm -> " Lm " | ` Lo -> " Lo " | ` Lt -> " Lt " | ` Lu -> " Lu " ... |
type ' a tree = | Empty | R of int * int * ' a | Rn of ' a tree * ' a tree * int * int * ' a |
type ' a t = { default : ' a ; tree : ' a tree } |
let get m cp = let rec loop cp = function | Rn ( l , r , is , ie , v ) -> if cp < is then loop cp l else if cp > ie then loop cp r else v | R ( is , ie , v ) -> if cp < is then m . default else if cp > ie then m . default else v | Empty -> m . default in loop cp m . tree |
let of_sorted_list default l = let rec loop len l = if len = 1 then match l with | ` R ( is , ie , v ) :: r -> R ( is , ie , v ) , r | _ -> assert false else let len_ll = len / 2 in let len_rl = len - len_ll in let ltree , rlist = loop len_ll l in match rlist with | [ ] -> lt... |
let height m = let rec loop = function | Empty -> 0 | R _ -> 1 | Rn ( l , r , _ , _ , _ ) -> 1 + max ( loop l ) ( loop r ) in loop m . tree |
let rec word_size v_size m = let rec loop = function | Empty -> 0 | R ( _ , _ , v ) -> 4 + v_size v | Rn ( l , r , _ , _ , v ) -> 6 + loop l + loop r + v_size v in loop m . tree |
let iter_values f m = let rec loop f = function | Empty -> ( ) | R ( _ , _ , v ) -> f v | Rn ( l , r , _ , _ , v ) -> f v ; loop f l ; loop f r in f m . default ; loop f m . tree |
let rec dump pp_v ppf m = let open Uucp_fmt in let rec dump_tree ppf = function | Rn ( l , r , is , ie , v ) -> pf ppf " [ @< 4 > Rn ( % a , , @% a , , @ 0x % 04X , , @ 0x % 04X , , @% a ) ] " @ dump_tree l dump_tree r is ie pp_v v | R ( is , ie , v ) ... |
type t = [ | ` Adlm | ` Aghb | ` Ahom | ` Arab | ` Armi | ` Armn | ` Avst | ` Bali | ` Bamu | ` Bass | ` Batk | ` Beng | ` Bhks | ` Bopo | ` Brah | ` Brai | ` Bugi | ` Buhd | ` Cakm | ` Cans | ` Cari | ` Cham | ` Cher | ` Chrs | ` Copt | ` ... |
let pp ppf s = Format . fprintf ppf " % s " begin match s with | ` Adlm -> " Adlm " | ` Aghb -> " Aghb " | ` Ahom -> " Ahom " | ` Arab -> " Arab " | ` Armi -> " Armi " | ` Armn -> " Armn " | ` Avst -> " Avst " | ` Bali -> " Bali " | ` Bamu -> "... |
type ' a t = { default : ' a ; l0 : ' a array array array } |
let l0_size = 0x10F + 1 |
let l1_size = 0xFF + 1 |
let l2_size = 0xF + 1 |
let create default = { default ; l0 = Array . make l0_size nil } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.