diff --git a/src/config.js b/src/config.js index 3f9c3be..0baa43f 100644 --- a/src/config.js +++ b/src/config.js @@ -16,6 +16,3 @@ export const PRICE_CHECK_TIMEOUT_INTERVAL = 1000 * 60 * 15; // 15 minutes /** Delay before removing iframes created during price checks */ export const IFRAME_TIMEOUT = 1000 * 60; // 1 minute - -// Minimum score to be considered the "correct" feature element extracted by Fathom -export const SCORE_THRESHOLD = 4; diff --git a/src/extraction/fathom_extraction.js b/src/extraction/fathom_extraction.js index 40328ae..00cebbc 100644 --- a/src/extraction/fathom_extraction.js +++ b/src/extraction/fathom_extraction.js @@ -12,9 +12,10 @@ import defaultCoefficients from 'commerce/extraction/fathom_default_coefficients.json'; import RulesetFactory from 'commerce/extraction/ruleset_factory'; -import {SCORE_THRESHOLD} from 'commerce/config'; const PRODUCT_FEATURES = ['title', 'price', 'image']; +// Minimum score to be considered the "correct" feature element extracted by Fathom +const SCORE_THRESHOLD = 4; // Array of numbers corresponding to the coefficients in order const coefficients = RulesetFactory.getCoeffsInOrder(defaultCoefficients); // For production, we don't need to generate a new ruleset factory diff --git a/src/extraction/ruleset_factory.js b/src/extraction/ruleset_factory.js index 5f6834d..8a9778e 100644 --- a/src/extraction/ruleset_factory.js +++ b/src/extraction/ruleset_factory.js @@ -12,9 +12,6 @@ import {dom, out, rule, ruleset, score, type} from 'fathom-web'; // Since the fathom-trainees add-on currently uses a submodule of Fathom, for // training, replace 'utils' with 'utilsForFrontend' import {ancestors} from 'fathom-web/utils'; -// relative URLs are needed for training, as the 'commerce' alias doesn't exist -// in that context -import {SCORE_THRESHOLD} from '../config'; const DEFAULT_BODY_FONT_SIZE = 14; const DEFAULT_SCORE = 1; @@ -296,8 +293,6 @@ export default class RulesetFactory { rule(dom('h1').when(this.isEligibleTitle.bind(this)), type('titleish')), // better score based on y-axis proximity to max scoring image element rule(type('titleish'), score(this.isNearbyImageYAxisTitle.bind(this))), - // since no further rules are needed for title, give all inputs the minimum score - rule(type('titleish'), score(() => SCORE_THRESHOLD)), // return title element(s) with max score rule(type('titleish').max(), out('title')), diff --git a/src/extraction/trainees.js b/src/extraction/trainees.js index 4254085..5ee6ce5 100644 --- a/src/extraction/trainees.js +++ b/src/extraction/trainees.js @@ -4,8 +4,8 @@ /* eslint-disable import/no-unresolved */ // This file is moved up a level to the ./src folder for training -import defaultCoefficients from './extraction/fathom_default_coefficients.json'; -import RulesetFactory from './extraction/ruleset_factory'; +import defaultCoefficients from 'fathom_default_coefficients.json'; +import RulesetFactory from 'ruleset_factory'; // Array of numbers corresponding to the coefficients in order const coeffs = RulesetFactory.getCoeffsInOrder(defaultCoefficients); @@ -22,9 +22,9 @@ const coeffs = RulesetFactory.getCoeffsInOrder(defaultCoefficients); * * How to train: * 1. Fork the `mozilla/fathom-trainees` repo, - * 2. In the `fathom-trainees` add-on, copy this file and `config.js` over to the - * `./src` folder, and copy `./extraction/fathom_default_coefficients.json` and - * `./extraction/ruleset_factory.js` to a new `./src/extraction` subfolder. + * 2. In the `fathom-trainees` add-on, copy this file, + * `./extraction/fathom_default_coefficients.json` and + * `./extraction/ruleset_factory.js` to the `./src` folder. * * Note: You will have to replace 'utils' with 'utilsForFrontend' on the * import in `ruleset_factory.js`. See that file for more information. * 3. Follow instructions at: https://github.com/erikrose/fathom-fox#the-trainer.