Skip to content

Commit

Permalink
relax criteria for uniqueness in CollectUnique
Browse files Browse the repository at this point in the history
  • Loading branch information
tongwang committed Nov 27, 2017
1 parent 63fa7e5 commit 1c05c32
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/assets/javascripts/components/browse/browse-panel.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ module.exports = React.createClass
{subj.data.category}
</div>
}

{
if subj.data.values && subj.data.values[0].caption
<div className="caption">
{subj.data.values[0].caption}
</div>
}
{
if subj.data.values && subj.data.values[0].creator
<div className="creator">
By {subj.data.values[0].creator}
</div>
}
{
if subj.data.values && subj.data.values[0].category
<div className="category">
{subj.data.values[0].category}
</div>
}

{
if subj.meta_data.subject_description
<div className="citation">
Expand Down
21 changes: 21 additions & 0 deletions app/assets/javascripts/components/view/view-panel.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ module.exports = React.createClass
{subj.data.category}
</div>
}

{
if subj.data.values && subj.data.values[0].caption
<div className="caption">
{subj.data.values[0].caption}
</div>
}
{
if subj.data.values && subj.data.values[0].creator
<div className="creator">
By {subj.data.values[0].creator}
</div>
}
{
if subj.data.values && subj.data.values[0].category
<div className="category">
{subj.data.values[0].category}
</div>
}


{
if subj.meta_data.subject_description
<div className="citation">
Expand Down
11 changes: 10 additions & 1 deletion app/models/subject_generation_methods/collect_unique.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def process_classification(classification)
if classification.child_subject.persisted?

values = classification.child_subject.data['values'].nil? ? [] : classification.child_subject.data['values']
values.push ann unless values.include? ann
if classification.workflow.fuzzy_match
values.push ann unless values.map {|x| scrub(x)}.include? scrub(ann)
else
values.push ann unless values.include? ann
end

atts[:data] = {'values' => values}

Expand Down Expand Up @@ -74,6 +78,11 @@ def process_classification(classification)
classification.child_subject
end

def scrub(annotation)
# remove all extra whitespaces and punctuations, convert to lower case
Hash[*annotation.map{|k,str| [k,str.gsub(/[[:punct:]]/, ' ').gsub(/\s+/, ' ').downcase.strip]}.flatten]
end

end

end
1 change: 1 addition & 0 deletions app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Workflow
field :order, type: Integer, default: 0
field :show_completion_assessment_task, type: Boolean, default: true
field :show_bad_subject_button, type: Boolean, default: true
field :fuzzy_match, type: Boolean, default: false

has_many :subjects
has_many :classifications
Expand Down
2 changes: 2 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ services:
mongodb:
image: mongo:2.6
command: mongod --setParameter textSearchEnabled=true
ports:
- 27017:27017
volumes:
- /Users/twan/data/db:/data/db

Expand Down
1 change: 1 addition & 0 deletions project/loc/workflows/transcribe.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"generates_subjects_after": 3,
"generates_subjects_method": "collect-unique",
"subject_fetch_limit": 50,
"fuzzy_match": true,

"tasks": {

Expand Down

0 comments on commit 1c05c32

Please sign in to comment.