Fork me on GitHub

I'm making an online japanese vocabulary quiz for the kanji (imported chinese glyphs) and their compounds.


Someone suggested that it would be cool to select which glyphs you already know so you can be fed only compounds that satisfy from the set of "known glyphs" you indicate


so i'm working on that! i'm stoked, it's pretty cool, but there are some weird things. is it okay to store these individual kanji like so?

(def all-tango (atom [{:tango "日" :kanji "日"}
{:tango "月" :kanji "月"}
{:tango "一月" :kanji ["月" "一"]}
{:tango "十月" :kanji ["月" "十"]}
{:tango "同月" :kanji "月"}
{:tango "会う" :kanji "会"}
{:tango "出る" :kanji "出"}
{:tango "出す" :kanji "出"}																						{:tango "同じ" :kanji "同"}]))

(def individual-kanji (atom [{:kanji "日"} {:kanji "会"}	{:kanji "同"}	{:kanji "月"}	{:kanji "一"}	{:kanji "十"}	{:kanji "出"}]))


As you can see, the individual pieces are noted, and you can click on them on the app and add them to an active set, i want to compare the active set with the :kanji list in the all-tango. (Tango means "vocabulary, words") so you can see each word and then what kanji are part of it.


Right now I don't know how to compare a collection of "known kanji" against the constituent parts of each vocab word in the all-tango atom.


@sova sets are perfect for this use case. you may use a set to store the constituent kanji of a tango (e.g., {:tango "一月" :kanji #{"月" "一"}}). you may use another set to store the "known kanji" (e.g., (def known-kanji #{"日" "同" "一" "出"}). from there on, you can use clojure.set/subset? to filter out tango(s) from the tango vector whose constituent kanji set is a subset of the known-kanji set.


i’m not in front of a computer right now. but i have a question: why are you keeping all-tango and individual-kanji in atoms?


it seems like these represent a known set of things that you can pick elements from and shouldn’t have a reason to change at runtime.


Great question! I'm making an online quiz. Maybe you can help me figure out what's most natural in Clojure. There's a set of all characters, you can click on them and add them to a known kanji atom (changes at run-time, during runtime) because it'll generate quizzes for you on compound words based on the ones you know.


Tango and All-Kanji never change, like you say, so what's a more relevant data structure? I've ingrained the atom access pattern it's all i use! haha


this is how i would do this: 1) figure out a way to get a list of tango from all-tango based on known-kanji for one round of the game (i.e., state for a single round). 2) leveraging what's in 1), use loop/`recur` to generate state for each round of a continuous game.


that's great. thank you, i agree! i didn't think about loop and recur, i will have to employ them !


I got it working. Set thinking was the way to go. I do a simple check if the intersection of kanji and the compounds is a superset of the compounds that make up a compoundword, and if that's true then i print it out. works very pretty so far ^_^

🎉 1

I need some help writing that filter

Ian Fernandez14:08:11

I'm using deps.edn in clojure in macOS

Ian Fernandez14:08:24

but It's not detecting my namespaces

Ian Fernandez14:08:37

{:paths   ["src/main"]
 :deps    {org.clojure/clojure {:mvn/version "1.10.1"}}
 :aliases {:test {:extra-paths ["test/main"]
                  :extra-deps  {lambdaisland/kaocha {:mvn/version "0.0-529"}}
                  :main-opts   ["-m" "kaocha.runner"]}}}

Ian Fernandez14:08:45

it's like this the deps.edn

Ian Fernandez14:08:06

the tree of files is:

├── bin
│   └── kaocha
├── deps.edn
├── src
│   └── main
│       └── core.clj
└── test
    └── main
        └── core_test.clj

Ian Fernandez14:08:49

the namespaces are: and for core.clj =>

(ns main.core)
and for core_test.clj =>
(ns main.core-test)

Ian Fernandez14:08:21

is there something wrong?


could you try changing :paths to only "src"?

clj 1
Ian Fernandez14:08:00

it worked, why


np! the namespaces start from the path, so with "src/main" it was expecting to find the files in src/main/main/core.clj.

👍 2

you should make the same change in :extra-paths as well


I am defining a rather long regex and am trying to split it over multiple lines. Currently I'm using re-pattern and constructing my string up of multiple fragments split over a few lines, though this means having to double escape. Is there a way to build up a regex over multiple lines without having to perform that double escaping? (e.g., #"\d{2}" must be written "\\d{2}")


user=> (re-pattern (str #"\d" #"\w"))


you can use the regex reader by using the #"" notation for each of the substrings


it combines as expected


you can also use format with %s instead of str if that makes things clearer (%s also does the right thing with an re input)

Michael Stokley20:08:06

i have a hash map with a key :@timestamp

Michael Stokley20:08:41

when i try to get the value it throws a syntax error Invalid token: :

Michael Stokley20:08:02

i've tried putting it in double quotes and escaping it with \

Michael Stokley20:08:04

i guess i could change it into a string... any other options folks may know of?


Sounds like elasticsearch. (keyword "@timestamp") should get you going

💯 1

It is constructable but not readable as a literal