GithubHelp home page GithubHelp logo

authoritex's Introduction

Authoritex

Build Coverage Hex.pm

An Elixir library for searching and fetching controlled vocabulary authority terms, inspired by the Samvera Community's Questioning Authority.

Installation

Add authoritex to your list of dependencies in mix.exs:

def deps do
  [
    {:authoritex, "~> 1.0.0"}
  ]
end

Configuration

Activate modules for the authorities you want to have available by configuring them in config/config.exs:

# To activate all 
config :authoritex,
  authorities: [
    Authoritex.FAST.CorporateName,
    Authoritex.FAST.EventName,
    Authoritex.FAST.Form,
    Authoritex.FAST.Geographic,
    Authoritex.FAST.Personal,
    Authoritex.FAST.Topical,
    Authoritex.FAST.UniformTitle,
    Authoritex.FAST,
    Authoritex.GeoNames,
    Authoritex.Getty.AAT,
    Authoritex.Getty.TGN,
    Authoritex.Getty.ULAN,
    Authoritex.Getty,
    Authoritex.Homosaurus,
    Authoritex.LOC.GenreForms,
    Authoritex.LOC.Languages,
    Authoritex.LOC.Names,
    Authoritex.LOC.SubjectHeadings,
    Authoritex.LOC
  ]

# Authoritex uses httpoison_retry https://github.com/mgwidmann/httpoison_retry
# Override the config in your application if needed
config :httpoison_retry,
  max_attempts: 3,
  wait: 1_000,
  retry_unknown_errors: false

Usage

See Authoritex.authorities/0, Authoritex.search/2, Authoritex.search/3, and Authoritex.fetch/1.

Implementing Additional Authorities

  • Create a module implementing the Authoritex behaviour
  • Create a test module using the Authoritex.TestCase module
  • Authoritex uses ExVCR to cache HTTP requests in the test suite. If you're seeing unexpected results during development, run mix vcr.delete CODE_ (where CODE is your authority module's unique short code) to clear that authority's cached results

Testing using mocks

See Authoritex.Mock

Supported Elixir/OTP versions

Authoritex supports (i.e., is tested against) a matrix consisting of the three most recent Elixir minor versions and up to three most recent Erlang/OTP major versions (depending on Elixir compatibility). Right now, that means:

Elixir/OTP 24 23 22
1.12 ✔️ ✔️ ✔️
1.11 ✔️ ✔️ ✔️
1.10 ✔️ ✔️

Support for other versions/combinations is possible (probable, even), but unsupported.

Contributing

Issues and Pull Requests are always welcome!

authoritex's People

Contributors

bmquinn avatar dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar kdid avatar kodiakhq[bot] avatar mbklein avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

authoritex's Issues

Extract Meadow lambdas into standalone serverless(?) apps

Description

In the interest of time we're coupling 3 lambdas that are potentially very reusable to the greater community into Meadow.

We should extract these into standalone repos and make available to the community.

There is a challenge when extracted of figuring out how to keep Meadow code bases in sync with the lambdas.

Done Looks Like

  • Meadow reconfigured w/out the bundled lambda code and Terraform deployments
  • create pyramid tif, generate file set digests, and characterization lambdas are deployed as separate repos

Rewrite Mock to handle known authorities

Description

Authoritex.Mock has no way to know whether a given unregistered URI is from an unknown authority or a missing ID from a known authority.

Current Implementation

Per #42, Authoritex.Mock.search("missing_id_authority:whatever") will return {:error, 404}, while any other unregistered URI will return {:error, :unknown_authority}

Proposed Implementation

  • Update Authoritex.Mock.set_data() to include a list of known authority prefixes along with the map of IDs and labels
  • Update Authoritex.Mock.fetch() to check the given URI against the list of registered authority prefixes (using String.starts_with? is sufficient)
    • If at least one authority prefix matches and the ID is registered, return the result as usual
    • If at least one authority prefix matches but the ID isn't found, the result is {:error, 404}
    • If no authority prefix matches even if the ID is found, the result is {:error, :unknown_authority}

Bibframe/LOC Linked Data Bug

Description

Authoritex's LOC (base) is not handling responses from Bibframe (Instances, Resources and Hubs) and returns an error.

We need to limit the query to not return bibframe results or otherwise handle.

** (CaseClauseError) no case clause matching: {:error, [message: {:bad_response, "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <bf:Work rdf:about=\"http://id.loc.gov/resources/works/11480615\" xmlns:bf=\"http://id.loc.gov/ontologies/bibframe/\">\n <bflc:aap xmlns:bflc=\"http://id.loc.gov/ontologies/bflc/\">Happy Pig Collectors Club. happy pig : the official publication of the Happy Pig Collectors Club</bflc:aap>\n <bflc:aap-normalized xmlns:bflc=\"http://id.loc.gov/ontologies/bflc/\">happypigcollectorsclubhappypig:theofficialpublicationofthehappypigcollectorsclub</bflc:aap-normalized>\n <rdf:type rdf:resource=\"http://id.loc.gov/ontologies/bibframe/Text\"/>\n <bf:language>\n <bf:Language rdf:about=\"http://id.loc.gov/vocabulary/languages/eng\">\n\t<rdfs:label xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">English</rdfs:label>\n </bf:Language>\n </bf:language>\n <bf:notation>\n <bf:Script rdf:about=\"http://id.loc.gov/vocabulary/mscript/a\">\n <rdfs:label xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">Basic roman</rdfs:label>\n </bf:Script>\n </bf:notation>\n <bf:identifiedBy>\n <bf:Lccn>\n <rdf:value>sf 97096996 </rdf:value>\n </bf:Lccn>\n </bf:identifiedBy>\n <bf:identifiedBy>\n <bf:Issn>\n 

Link to internal NU issue: https://github.com/nulib/repodev_planning_and_docs/issues/1162

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.