<commit_before>/* global $, AC, libreviews */
'use strict';

// Internal deps
const AbstractAutocompleteAdapter = require('./abstract-autocomplete-adapter');

/**
 * Perform book metadata lookups on openlibrary.org. Like other frontend
 * adapters, it is shallow and does not care for language, authorship,
 * or other details.
 *
 * @extends AbstractAutocompleteAdapter
 */
class OpenLibraryAutocompleteAdapter extends AbstractAutocompleteAdapter {

  /**
   * See {@link AbstractAutocompleteAdapter} for parameter documentation, not
   * shown here due to [jsdoc bug](https://github.com/jsdoc3/jsdoc/issues/1012).
   *
   * @inheritdoc
   */
  constructor(updateCallback, searchBoxSelector) {
    super(updateCallback, searchBoxSelector);

    // Standard adapter settings
    this.sourceID = 'openlibrary';
    this.supportedPattern = new RegExp('^https*://openlibrary.org/(works|books)/(OL[^/.]+)(?:/(?:.*))*$', 'i');

    /**
     * How many results to get per query. This is pretty low since a result
     * takes up a fair amount of space in the UI, esp. on mobile.
     *
     * @type {Number}
     */
    this.limit = 6;
  }


  /**
   * Obtain data from Open Library for a given URL.
   *
   * @param {String} url
   *  URL to an Open Library book or work
   * @returns {Promise}
   *  resolves to a {@link LookupResult} if successful, rejects with an error
   *  if not
   */   <commit_msg>whitespace fix<commit_after>/* global $, AC, libreviews */
'use strict';

// Internal deps
const AbstractAutocompleteAdapter = require('./abstract-autocomplete-adapter');

/**
 * Perform book metadata lookups on openlibrary.org. Like other frontend
 * adapters, it is shallow and does not care for language, authorship,
 * or other details.
 *
 * @extends AbstractAutocompleteAdapter
 */
class OpenLibraryAutocompleteAdapter extends AbstractAutocompleteAdapter {

  /**
   * See {@link AbstractAutocompleteAdapter} for parameter documentation, not
   * shown here due to [jsdoc bug](https://github.com/jsdoc3/jsdoc/issues/1012).
   *
   * @inheritdoc
   */
  constructor(updateCallback, searchBoxSelector) {
    super(updateCallback, searchBoxSelector);

    // Standard adapter settings
    this.sourceID = 'openlibrary';
    this.supportedPattern = new RegExp('^https*://openlibrary.org/(works|books)/(OL[^/.]+)(?:/(?:.*))*$', 'i');

    /**
     * How many results to get per query. This is pretty low since a result
     * takes up a fair amount of space in the UI, esp. on mobile.
     *
     * @type {Number}
     */
    this.limit = 6;
  }


  /**
   * Obtain data from Open Library for a given URL.
   *
   * @param {String} url
   *  URL to an Open Library book or work
   * @returns {Promise}
   *  resolves to a {@link LookupResult} if successful, rejects with an error
   *  if not
   */
{'fraction_non_alphanumeric': 0.12142857142857143, 'fraction_numerical': 0.004285714285714286, 'mean_word_length': 3.237518910741301, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '3103492', 'n_tokens_mistral': 839, 'n_tokens_neox': 806, 'n_words': 267}