Skip to content

Instantly share code, notes, and snippets.

@jbaiter
Created March 1, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbaiter/47438286323f51d4582f to your computer and use it in GitHub Desktop.
Save jbaiter/47438286323f51d4582f to your computer and use it in GitHub Desktop.
(defn linking-tool [tags tokens empty_tag]
(let [show-suggestions (subscribe [:get :show-suggestions])]
(fn []
(log "Called with: " tags)
[:div.linking-tool
[:table.table>tbody
(doall
(for [[idx {:keys [tokens tag] :as ent}]
(indexed (extract-entities tokens tags empty_tag))]
(let [name (string/join " " tokens)
query-key (str name "." tag)
show-suggs? (get @show-suggestions query-key)]
^{:key idx}
[:tr
[:td name]
[:td
[:a.button {:on-click #(dispatch [:set [:show-suggestions query-key] (not show-suggs?)])}
"Show suggestions"]
(when show-suggs?
[linking-suggestions query-key])]
[:td [:a.icon {:on-click #(dispatch [:query-gnd ent])}
[icon :search]]]])))]])))
(defn tagging-panel []
(let [sentence (subscribe [:get :active-sentence])
sentences (subscribe [:get :sentences])
project (subscribe [:active-project])
fetching? (subscribe [:get :loading? :initial-sentences])]
(fn []
(let [{:keys [tagset id]} @project
{:keys [tags empty_tag]} tagset
tag-colors (make-tag-colors tagset)]
[:section.hero.is-fullheight.tagging-container
[:div.hero-content
[:div.container
(if @fetching?
[:div.loading-spinner]
[:div
[tagging-info]
[tagging-sentence (:tokens @sentence) (:tags @sentence)
tag-colors empty_tag]
(when (has-entities? (:tags @sentence) empty_tag)
(do
(log "Calling with: " (:tags @sentence))
[linking-tool (:tags @sentence) (:tokens @sentence) empty_tag]))])]
(when-not @fetching?
[tagging-toolbar id (not (empty? @sentences))])]]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment