text stringlengths 0 601k |
|---|
let kSpoofingVariant = KSpoofingVariant , o_string |
let kSrc_NushuDuben = KSrc_NushuDuben , o_string |
let kStrange = KStrange , o_string |
let kTGH = KTGH , o_string |
let kTGHZ2013 = KTGHZ2013 , o_string |
let kTGT_MergedSrc = KTGT_MergedSrc , o_string |
let kTaiwanTelegraph = KTaiwanTelegraph , o_string |
let kTang = KTang , o_string |
let kTotalStrokes = KTotalStrokes , o_string |
let kTraditionalVariant = KTraditionalVariant , o_string |
let kUnihanCore2020 = KUnihanCore2020 , o_string |
let kVietnamese = KVietnamese , o_string |
let kWubi = KWubi , o_string |
let kXHC1983 = KXHC1983 , o_string |
let kXerox = KXerox , o_string |
let kZVariant = KZVariant , o_string |
type block = ( cp * cp ) * string |
type named_sequence = string * cp list |
type normalization_correction = cp * cp list * cp list * ( int * int * int ) |
type standardized_variant = cp list * string * [ ` Isolate | ` Initial | ` Medial | ` Final ] list |
type cjk_radical = string * cp * cp |
type emoji_source = cp list * int option * int option * int option |
type t = { description : string ; repertoire : props Cpmap . t ; blocks : block list ; named_sequences : named_sequence list ; provisional_named_sequences : named_sequence list ; normalization_corrections : normalization_correction list ; standardized_variants : standardized_variant list ; cjk_radicals : cjk_radical li... |
let cp_props db cp = try Some ( Cpmap . find cp db . repertoire ) with Not_found -> None |
let cp_prop db cp p = try find ( Cpmap . find cp db . repertoire ) p |
let n_block = ( ns_ucd , " block " ) |
let n_blocks = ( ns_ucd , " blocks " ) |
let n_char = ( ns_ucd , " char " ) |
let n_cjk_radical = ( ns_ucd , " cjk - radical " ) |
let n_cjk_radicals = ( ns_ucd , " cjk - radicals " ) |
let n_description = ( ns_ucd , " description " ) |
let n_emoji_source = ( ns_ucd , " emoji - source " ) |
let n_emoji_sources = ( ns_ucd , " emoji - sources " ) |
let n_group = ( ns_ucd , " group " ) |
let n_name_alias = ( ns_ucd , " name - alias " ) |
let n_named_sequence = ( ns_ucd , " named - sequence " ) |
let n_named_sequences = ( ns_ucd , " named - sequences " ) |
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 " Bidi_M " ( Bidi_mirrored , i_bool ) ; map " Cased " ( Ca... |
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 | ` El_end -> List . rev acc | ` Data _ -> err... |
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 | ( " " , " type " ) , v -> atype := Some ( i_name_... |
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_string v ) ; acc | ( " " , " last - cp " ) -> cp_last := ... |
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_start ( n , atts ) when n = n_noncharacter -> loop d (... |
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 " cp " atts ) , cps_of_string ( attv " old " atts ... |
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 = cps_of_string ( attv " cps " atts ) , attv " desc ... |
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_emoji_source es_atts d |
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 = ref Non... |
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 | ` Arabic_PF_B | ` Arabic_Sup | ` Armenian | ` Arrows ... |
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_Hieroglyphs -> " Anatolian_Hieroglyphs " | ` Ancient_Greek_Musi... |
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_max = grapheme_cluster_max... |
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 | u when ( let c = gc u in c = ` Mn || c... |
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 | ` OP | ` PO | ` PR | ` QU | ` RI | ` SA | ` SG | ` SP | ` SY | ` WJ | ` XX | ` ZW | ` ZWJ ] |
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 ; ` JV ; ` LF ; ` NL ; ` NS ; ` NU ; ` OP ; ` PO ; ` PR ; ` QU ; ` RI ; ` SA ; ` SG ; ` SP ; ` SY ; ` WJ ; ` XX... |
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 -> " CM " | ` CP -> " CP " | ` CR -> " CR " | ` EX -> " EX " | ` EB -> " EB " | ` EM -> " EM... |
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 " | ` LV -> " LV " | ` LVT -> " LVT " | ` PP -> " PP " | ` RI -> " RI " | ` SM -> " SM ... |
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 " | ` HL -> " HL " | ` KA -> " KA " | ` LE -> " LE " | ` LF -> " LF " | ` MB -> " MB " | ... |
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 -> " SC " | ` SE -> " SE " | ` SP -> " SP " | ` ST -> " ST " | ` UP -> " UP " | ` XX -> ... |
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 , [ ] | ` C ( i , v ) :: r -> if len_rl = 1 then Cn ... |
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 % 04X , , @% a ) ] " @ i pp_v v | Empty -> pf ppf " Empty " in record [... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.