TL;DR
I’m happy to annouce the release of following packages. Have a try!
- GitHub - AtelierArith/DocstringTranslation.jl: Translate docstrings in Julia using your preferred language.
- GitHub - AtelierArith/DocstringTranslationOllamaBackend.jl: DocstringTranslation using Ollama
- GitHub - AtelierArith/DocstringTranslationGoogleTransBackend.jl: Translate Julia's docstring using googletrans
- GitHub - AtelierArith/DocstringTranslationExoBackend.jl: Translate Julia's docstrings using `exo`: Run your own AI cluster at home with everyday devices
- GitHub - AtelierArith/DocstringChef.jl: May I explain something?
Introduction (You can skip)
The Julia Programming Language solves the so-called “two-language problem.” 2 - 1 = 1, which is fantastic news for those in the scientific domain.
What about natural languages? I believe that there are still (N>1)-language problem.
I mean, non-native English speaker people have to learn natural language so called English.
Let me tell you what the issue is on this one.
I’m Japanese. I’m not a native English speaker, but I write my thoughts in English. Why? Many people in the world do not nor cannot read my native language(=Japanese 日本語) directly(i.e., without translation). People here, Julia Discourse, use English, so I use English. Yes, I know, of course, that English is an official language in many countries and territories. This is a natural consequence.
When it comes to writing something in English, Japanese people suffer from translating because the word order between Japanese and English is different. For instance, consider the following example:
# This is Japanese
私はホテルの向かいにあるお店で見たスーツを着てみたいです.
Can you translate it into English IMMEDIATELY without machine translation? You can see the answer here:
Did you see the answer? O.K. One more time. May I ask a question?
Can you translate it into English IMMEDIATELY without machine translation again?
In the context of the Julia language, Japanese Julia programmers execute source code in their brains as below in order to communicate with you.
en_str = process(reverse(collect("WhatIwantToSayIterator{Japanese}()")), dict=JP2EN)
If you are a good Julia programmer, this implementation looks slow. That’s true. How much time do I spend writing my messy English to explain my thoughts?
The process
function is complicated. Let me show my messy implementation in Julia in my brain.
# Vocabulary list
# Well, I'll do my best.
const JP2EN = Dict(
"私" => "I",
"スーツ" => "suit",
"お店" => "store",
...
)
abstract type Tense end
abstract type JapanesePastTense <: Tense end
"""
_dispatch(tense, ctx)
Determies Japanese "... した" in ctx is a past tense or perfect tense.
In Japanese, there is no distinction between them.
"""
function _dispatch(tense, ctx)
# Actually I don't know how to implement.
# I use DeepL/Write or Grammarly. Don't say to me I'm cheating.
end
function dispatchtense(tense::Tense, ctx::Context)
tense isa JapanesePastTense
if _dispatch(tense, ctx) isa PastTense
return convert(PastTense, tense)
else
return convert(PerfectTense, tense)
end
else
PresentTense(tense)
end
end
function processverb(;v, tense::PerfectTense)
return "have " * v * "ed"
end
function processverb(;v, tense::PerfectTense)
return "" * v * "ed"
end
"""
process(w::Word, ctx::Context)
do something complicated which is a nightmare for Japanese
"""
function process(w::Word, ctx::Context)
if w isa Verb
tense = determinetense(ctx)
if tense isa PresentTense
# "use" becomes "uses"
# but, "study" also "studys" oh no... should be "studies"
w *= "s"
return w
else
processverb(;v=w, tense)
end
else
# This implementation is slow and inaccurate.
if isdefinite(w)
w = "a " * w
elseif isdefinite(w)
w = "the " * w
end
end
end
function process(sentence::String)
context = Context()
for w in sentence
process(w::Word, context)
end
end
en_str = process(
reverse(collect("<What I want to say>")), dict=JP2EN
)
Geez… The joke is over. Back to more and talk about more serious topics.
In short, as for me at least, reading, writing and speaking English is NON-trivial task. Can we relax the matter in technology?
Introduction (It would be nice to read)
Have you ever wanted to understand docstrings in Julia API in your preferred language? Your dream can be solved by using the Machine Learning API, which you can use right away if you have an OpenAI API key. Try it out my Julia package named DocstringTranslation.jl.
Demo
Related packages
If you are not willing to pass something to OpenAI’s API, you can use local LLM. Ollama will help you.
Using the Google translation API is another solution.
(Warning, this package is unstable.)
If you want to make OpenAI generate docstring or explain something from a user given function, try DocstringChef.jl
I hope my packages reduce N-language problems. Let’s read docstrings in preferred language.
Feedback is welcome. Leave your comment in your preferred language :D.