Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #6

Merged
merged 4 commits into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PolytonicGreek"
uuid = "72b824a7-2b4a-40fa-944c-ac4f345dc63a"
authors = ["nsmith "]
version = "0.1.0"
version = "0.1.1"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
84 changes: 84 additions & 0 deletions pluto/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,118 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "50ddf44c53698f5e784bbebb3f4b21c5807401b1"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.3"

[[Documenter]]
deps = ["Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "b7715ae18be02110a8cf9cc8ed2ccdb1e3e3aba2"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.26.1"

[[IOCapture]]
deps = ["Logging"]
git-tree-sha1 = "377252859f740c217b936cebcd918a44f9b53b59"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.1.1"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.1"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[Orthography]]
deps = ["DocStringExtensions", "Documenter", "Test"]
git-tree-sha1 = "53ae798c10043b4a990d1557a594388b0e07a57a"
uuid = "0b4c9448-09b0-4e78-95ea-3eb3328be36d"
version = "0.4.1"

[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "50c9a9ed8c714945e01cd53a21007ed3865ed714"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.0.15"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PlutoUI]]
deps = ["Base64", "Dates", "Logging", "Markdown", "Random", "Suppressor"]
git-tree-sha1 = "e453271bb6e5493e1fd98d72752ab1a9ee1eb6a6"
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
version = "0.6.11"

[[PolytonicGreek]]
deps = ["DocStringExtensions", "Documenter", "Orthography", "Test", "Unicode"]
git-tree-sha1 = "a943a5557c26473dc01d89c6528a4e51b03fa833"
repo-rev = "main"
repo-url = "https://github.com/neelsmith/PolytonicGreek.jl"
uuid = "72b824a7-2b4a-40fa-944c-ac4f345dc63a"
version = "0.1.0"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[Suppressor]]
git-tree-sha1 = "a819d77f31f83e5792a76081eee1ea6342ab8787"
uuid = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
version = "0.2.0"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
7 changes: 7 additions & 0 deletions pluto/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[deps]
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
PolytonicGreek = "72b824a7-2b4a-40fa-944c-ac4f345dc63a"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[compat]
PlutoUI = "0.6"
PolytonicGreek = "0.1"
161 changes: 158 additions & 3 deletions pluto/literaryGreek.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,177 @@
using Markdown
using InteractiveUtils

# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
el
end
end

# ╔═╡ 07723886-6564-11eb-2f61-65638d4bfb6c
begin
using Pkg
Pkg.activate(".")
# Pkg.add("PolytonicGreek")
# using PolytonicGreek
Pkg.instantiate()

using Markdown
using PlutoUI
using Unicode
using PolytonicGreek
end


# ╔═╡ 3da4ca0a-6565-11eb-1b92-b9c1553f3223
md"Define environment in hidden cell."

# ╔═╡ ee5aa2c2-6563-11eb-1f3a-6b907e19fd31
md"Walkthrough of `LiteraryGreekOrthography`"
md"# Introduction to `LiteraryGreekOrthography`"

# ╔═╡ 7dcc46bc-656a-11eb-0f29-01dd8a59d645
md"""
Load the library:

```julia
using PolytonicGreek
```

"""

# ╔═╡ 937d959e-656a-11eb-2303-7da51f1b0482
md"""

## Tokenization

Tokenize a string:

```julia
str = "Μῆνιν ἄειδε, θεά, Πηληϊάδεω Ἀχιλῆος,"
tkns = tokenizeLiteraryGreek(str)
```
"""

# ╔═╡ 5c89aa08-656a-11eb-3d95-cb47ee3892aa
str = "Μῆνιν ἄειδε, θεά, Πηληϊάδεω Ἀχιλῆος,"

# ╔═╡ 6d3f90a6-656a-11eb-14d9-2b229f0d6a11
tkns = tokenizeLiteraryGreek(str)

# ╔═╡ c9fb0c94-656a-11eb-2c35-5189c1360656
md"Tokens have a string value and a category."

# ╔═╡ d3c8c950-656a-11eb-1ff4-ebd936142caf
begin
items = map(t -> "1. **" * t.text * "** (*$(t.tokencategory)*)", tkns)
itemstring = join(items, "\n")
Markdown.parse("**Tokens**:\n" * itemstring)
end

# ╔═╡ e0518030-656b-11eb-0258-9756bc71d49f
md"""
## Orthographic categorization and validation

All characters are precomposed in Unicode form NFKC
"""

# ╔═╡ 081371e6-656c-11eb-2f79-bf0067480cd6
md"Recognize category of a string"

# ╔═╡ 131640be-656c-11eb-1e3f-7967f02c46a4
PolytonicGreek.isPunctuation(";")

# ╔═╡ 2515ee86-656c-11eb-1bcf-bd862a853538
PolytonicGreek.isAlphabetic("μῆνιν")

# ╔═╡ 14d71e8a-656e-11eb-2eee-092306f81a29
md"""

---
"""

# ╔═╡ 1c93f238-656e-11eb-11ed-5df25da03158
md"All recognized punctuation characters:"

# ╔═╡ 2557a112-656e-11eb-2046-9361e24dcccc
PolytonicGreek.punctuation()

# ╔═╡ b8a3cb52-656a-11eb-0523-034cb44b8955
md"""

All recognized alphabetic characters (in Unicode order):
"""

# ╔═╡ 9bc2dfda-656c-11eb-284e-5750c39f56db
md"""

*Display one character per line*: $(@bind byline CheckBox())

"""

# ╔═╡ 07d856cc-6573-11eb-2f25-af7805e01de6
md">Some formatting functions"

# ╔═╡ 1b37606a-6572-11eb-265d-796b2e421c17
function ucat(cp)
if Unicode.isnumeric(cp)
"numeric"
elseif Unicode.ispunct(cp)
"punctuation"
elseif Unicode.isletter(cp)
"letter"
else
"uncrecognized category"
end
end


# ╔═╡ c35e1238-656e-11eb-2092-85f48cdc3bab
function stringinfo(s)
#string(s, " (" , length(s) , ")")


uc = Unicode.islowercase(s[begin]) ? "lowercase" : "uppercase"

string("**", s, "** (*Unicode ", codepoint(s[begin]) , ", ", ucat(s[begin]), " ", uc, "*)")

end

# ╔═╡ 56830e2c-656c-11eb-0a42-b59d378ee995
begin
if byline

chlist = []
for ch in PolytonicGreek.alphabetic()
push!(chlist, "- " * stringinfo(ch))
end
Markdown.parse(join(chlist,"\n"))
else
md"$(PolytonicGreek.alphabetic())"

end
end

# ╔═╡ Cell order:
# ╟─3da4ca0a-6565-11eb-1b92-b9c1553f3223
# ╟─07723886-6564-11eb-2f61-65638d4bfb6c
# ╟─ee5aa2c2-6563-11eb-1f3a-6b907e19fd31
# ╟─7dcc46bc-656a-11eb-0f29-01dd8a59d645
# ╟─937d959e-656a-11eb-2303-7da51f1b0482
# ╟─5c89aa08-656a-11eb-3d95-cb47ee3892aa
# ╟─6d3f90a6-656a-11eb-14d9-2b229f0d6a11
# ╟─c9fb0c94-656a-11eb-2c35-5189c1360656
# ╟─d3c8c950-656a-11eb-1ff4-ebd936142caf
# ╟─e0518030-656b-11eb-0258-9756bc71d49f
# ╟─081371e6-656c-11eb-2f79-bf0067480cd6
# ╠═131640be-656c-11eb-1e3f-7967f02c46a4
# ╠═2515ee86-656c-11eb-1bcf-bd862a853538
# ╟─14d71e8a-656e-11eb-2eee-092306f81a29
# ╟─1c93f238-656e-11eb-11ed-5df25da03158
# ╠═2557a112-656e-11eb-2046-9361e24dcccc
# ╟─b8a3cb52-656a-11eb-0523-034cb44b8955
# ╟─9bc2dfda-656c-11eb-284e-5750c39f56db
# ╟─56830e2c-656c-11eb-0a42-b59d378ee995
# ╟─07d856cc-6573-11eb-2f25-af7805e01de6
# ╟─c35e1238-656e-11eb-2092-85f48cdc3bab
# ╟─1b37606a-6572-11eb-265d-796b2e421c17
9 changes: 7 additions & 2 deletions src/ortho.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ function alphabetic()
'\u1f5d' ; '\u1f5f':'\u1f7d' ;
'\u1f80':'\u1faf'; '\u1fb2':'\u1fb4' ;
'\u1fb6':'\u1fbc';
'\u1fc5':'\u1fcc';
'\u1fd2':'\u1fd3'; '\u1fd6':'\u1fdc';
'\u1fc2':'\u1fc4';
'\u1fc6':'\u1fcc';
'\u1fd2':'\u1fd3'; '\u1fd6':'\u1fdb';
'\u1fe2':'\u1fe7';
'\u1fea':'\u1fec';
'\uf1f2':'\u1ff4'; '\u1ff6':'\u1ffc'
Expand Down Expand Up @@ -74,6 +75,10 @@ end
function isAlphabetic(s::AbstractString)
chlist = split(s,"")
alphas = alphabetic()
tfs = []
for i in collect(eachindex(s))
push!(tfs, occursin(s[i], alphas))
end
tfs = map(c -> occursin(c, alphas), chlist)
nogood = false in tfs

Expand Down