-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Detector, Category, DetectorCategory
** Why are these changes being introduced: Our chosen architecture calls for a set of models that will comprise a sort of "knowledge graph", which TACOS will consult during the categorization process. This includes classes for Category, Detector, and a linking DetectorCategory class. The Detector and DetectorCategory classes will each define a confidence value. ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/tco-82 ** How does this address that need: This defines those classes. The migration includes the creation of the needed records for each class: Three category records, six detectors, and five records which link between them. There are currently no detectors which map to two of the categories, although we have talked about those being needed. Additionally, one detector, SuggestedResource, is unique in that specific records will count toward each category - so it isn't appropriate to have a link record which uniformly connects to only one category. ** Document any side effects to this change: We previously had a Detector model file, but it was set as a Module in order to provide a namespace for its subclasses. This has been updated to be just a class, which impacts the dashboard and test files. Also, there was a method to define a table name prefix, which has been moved from the Detector file to the subclass files.
- Loading branch information
1 parent
02fc057
commit 9c3bb23
Showing
12 changed files
with
101 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Category < ApplicationRecord | ||
has_many :detector_categories | ||
has_many :detectors, through: :detector_categories | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class DetectorCategory < ApplicationRecord | ||
belongs_to :category | ||
belongs_to :detector | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class CreateCategories < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :detectors do |t| | ||
t.string :name | ||
t.float :confidence | ||
|
||
t.timestamps | ||
end | ||
|
||
create_table :categories do |t| | ||
t.string :name | ||
t.text :description | ||
|
||
t.timestamps | ||
end | ||
|
||
create_table :detector_categories do |t| | ||
t.belongs_to :detector, null: false, foreign_key: true | ||
t.belongs_to :category, null: false, foreign_key: true | ||
t.float :confidence | ||
|
||
t.timestamps | ||
end | ||
|
||
Detector.create(name: 'DOI', confidence: 0.95) | ||
Detector.create(name: 'ISBN', confidence: 0.8) | ||
Detector.create(name: 'ISSN', confidence: 0.6) | ||
Detector.create(name: 'PMID', confidence: 0.95) | ||
Detector.create(name: 'Journal', confidence: 0.2) | ||
Detector.create(name: 'SuggestedResource', confidence: 0.95) | ||
|
||
Category.create(name: 'Informational', description: 'A type of search where the user is looking for broad information, rather than an individual item. Also known as "open-ended" or "topical".') | ||
Category.create(name: 'Navigational', description: 'A type of search where the user has a location in mind, and wants to go there. In library discovery, this should mean a URL that will not be in the searched index.') | ||
Category.create(name: 'Transactional', description: 'A type of search where the user has an item in mind, and wants to get that item. Also known as "known-item".') | ||
|
||
DetectorCategory.create(detector: Detector.find_by(name: 'DOI'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'ISBN'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'ISSN'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'PMID'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'Journal'), category: Category.find_by(name: 'Transactional'), confidence: 0.5) | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters