<commit_before># frozen_string_literal: true
#   Copyright 2015 Australian National Botanic Gardens
#
#   This file is part of the NSL Editor.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#  Reference entity - books, papers, journals, etc
class Reference < ActiveRecord::Base
  include PgSearch
  self.table_name = "reference"
  self.primary_key = "id"
  self.sequence_name = "nsl_global_seq"
  strip_attributes

  attr_accessor :display_as, :message

  # https://github.com/Casecommons/pg_search
  pg_search_scope :search_citation_text_for,
                  against: :citation,
                  ignoring: :accents,
                  using: {
                    tsearch: {
                      dictionary: "english",
                      prefix: "true",
                    }
                  }

  # https://robots.thoughtbot.com/optimizing-full-text-search-with-postgres-
  # tsvector-columns-and-triggers
  pg_search_scope :search_citation_tsv_for,
                  against: :citation,
                  using: {
                    tsearch: {
                      tsvector_column: "tsv",
                      dictionary: "english",
                      prefix: "true",
                    }
                  }
<commit_msg>Require open-uri in reference model - so ruby opens the string as a resource not as a file; not sure why needed now.<commit_after># frozen_string_literal: true
#   Copyright 2015 Australian National Botanic Gardens
#
#   This file is part of the NSL Editor.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#  Reference entity - books, papers, journals, etc
class Reference < ActiveRecord::Base
  include PgSearch
  require 'open-uri'
  self.table_name = "reference"
  self.primary_key = "id"
  self.sequence_name = "nsl_global_seq"
  strip_attributes

  attr_accessor :display_as, :message

  # https://github.com/Casecommons/pg_search
  pg_search_scope :search_citation_text_for,
                  against: :citation,
                  ignoring: :accents,
                  using: {
                    tsearch: {
                      dictionary: "english",
                      prefix: "true",
                    }
                  }

  # https://robots.thoughtbot.com/optimizing-full-text-search-with-postgres-
  # tsvector-columns-and-triggers
  pg_search_scope :search_citation_tsv_for,
                  against: :citation,
                  using: {
                    tsearch: {
                      tsvector_column: "tsv",
                      dictionary: "english",
                      prefix: "true",
                    }
                  }

{'fraction_non_alphanumeric': 0.07796143250688706, 'fraction_numerical': 0.004407713498622589, 'mean_word_length': 2.069315300084531, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5405626', 'n_tokens_mistral': 999, 'n_tokens_neox': 941, 'n_words': 309}