From e2fc37e9691f886f96afe1fca15f77b6ac77f005 Mon Sep 17 00:00:00 2001 From: Tan Kian-ting Date: Sun, 27 Aug 2023 03:56:41 +0800 Subject: [PATCH] add v 0.0.1 --- dune-project | 27 ++++++++++++++ lib/dune | 4 ++ .../stringCodepointSplitter.ml | 12 ++---- stringCodepointSplitter.opam | 37 +++++++++++++++++++ stringCodepointsSplitter.opam | 21 ----------- test/dune | 2 + test/stringCodepointSplitter.ml | 0 7 files changed, 74 insertions(+), 29 deletions(-) create mode 100644 dune-project create mode 100644 lib/dune rename stringCodepointSplitter.ml => lib/stringCodepointSplitter.ml (90%) create mode 100644 stringCodepointSplitter.opam delete mode 100644 stringCodepointsSplitter.opam create mode 100644 test/dune create mode 100644 test/stringCodepointSplitter.ml diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..2b51940 --- /dev/null +++ b/dune-project @@ -0,0 +1,27 @@ +(lang dune 3.9) + +(name stringCodepointSplitter) +(version 0.0.1) +(generate_opam_files true) + +(source + (github yoxem/stringCodepointSplitter)) + +(authors "Tan Kian-ting ") + +(maintainers "Tan Kian-ting ") +(bug_reports https://github.com/Yoxem/stringCodepointSplitter/issues) +(license MIT) + +(documentation https://github.com/Yoxem/stringCodepointSplitter/tree/main/docs) + +(package + (name stringCodepointSplitter) + (synopsis "Split a string to a list of strings of a character by the unicode codepoint") + (description "Split a string to a list of strings of a character by the unicode codepoint. + +It requires module Uutf.") + (depends ocaml>=4.14 dune uutf) + (tags (string utf8))) + +; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project diff --git a/lib/dune b/lib/dune new file mode 100644 index 0000000..7ae24b9 --- /dev/null +++ b/lib/dune @@ -0,0 +1,4 @@ +(library + (name stringCodepointSplitter) + (public_name stringCodepointSplitter) + (libraries uutf findlib.dynload)) diff --git a/stringCodepointSplitter.ml b/lib/stringCodepointSplitter.ml similarity index 90% rename from stringCodepointSplitter.ml rename to lib/stringCodepointSplitter.ml index 4464364..1ad5a51 100644 --- a/stringCodepointSplitter.ml +++ b/lib/stringCodepointSplitter.ml @@ -1,13 +1,13 @@ -(*#use "topfind";;*) open Stdlib -open Uutf - (** The Module needs [Uutf] Module. It only contains [split_string_by_unicode_codepoint], which splits an OCaml string [str] to a [string list] *) +let _ = Findlib.init ();; +Fl_dynload.load_packages ["uutf"];; + (** Split an OCaml string [str] to a [string list] @@ -28,7 +28,7 @@ let split_string_by_unicode_codepoint str = (*Split a Ocaml string [str] to a `str list` *) let pred_codepoint = ref (-1) in let segmented_unit_list = ref [] in - let iterator x y z = + let iterator x y _ = let _ = if !pred_codepoint > -1 then let current_codepoint = y in let pred_char_len = current_codepoint - !pred_codepoint in @@ -48,7 +48,3 @@ let split_string_by_unicode_codepoint str = else !segmented_unit_list;; - -List.map (fun x -> print_string (x ^ ", ")) (split_string_by_unicode_codepoint "m̄知 who you're.");; - - diff --git a/stringCodepointSplitter.opam b/stringCodepointSplitter.opam new file mode 100644 index 0000000..38f22d2 --- /dev/null +++ b/stringCodepointSplitter.opam @@ -0,0 +1,37 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +version: "0.0.1" +synopsis: + "Split a string to a list of strings of a character by the unicode codepoint" +description: """ +Split a string to a list of strings of a character by the unicode codepoint. + +It requires module Uutf.""" +maintainer: ["Tan Kian-ting "] +authors: ["Tan Kian-ting "] +license: "MIT" +tags: ["string" "utf8"] +homepage: "https://github.com/yoxem/stringCodepointSplitter" +doc: "https://github.com/Yoxem/stringCodepointSplitter/tree/main/docs" +bug-reports: "https://github.com/Yoxem/stringCodepointSplitter/issues" +depends: [ + "ocaml>=4.14" + "dune" {>= "3.9"} + "uutf" + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/yoxem/stringCodepointSplitter.git" diff --git a/stringCodepointsSplitter.opam b/stringCodepointsSplitter.opam deleted file mode 100644 index a6b45b4..0000000 --- a/stringCodepointsSplitter.opam +++ /dev/null @@ -1,21 +0,0 @@ -opam-version: "2.0" -name: "stringCodepointSplitter" -version: "0.1" -synopsis: "Split a string to a list of strings of a character by the unicode codepoint" -description: """ -Split a string to a list of strings of a character by the unicode codepoint. - -It requires module Uutf. -""" -maintainer: "Tan Kian-ting " -authors: "Tan Kian-ting " -license: "MIT License" -homepage: "https://github.com/Yoxem/stringCodepointSplitter" -bug-reports: "https://github.com/Yoxem/stringCodepointSplitter/issues" -dev-repo: "https://github.com/Yoxem/stringCodepointSplitter" -depends: [ "ocaml" "uutf" ] -build: [ - ["./configure" "--prefix=%{prefix}%"] - [make] -] -install: [make "install"] \ No newline at end of file diff --git a/test/dune b/test/dune new file mode 100644 index 0000000..abafc95 --- /dev/null +++ b/test/dune @@ -0,0 +1,2 @@ +(test + (name stringCodepointSplitter)) diff --git a/test/stringCodepointSplitter.ml b/test/stringCodepointSplitter.ml new file mode 100644 index 0000000..e69de29