Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
Fix #36: Remove 'SCORE_THRESHOLD' const from config.js.
Browse files Browse the repository at this point in the history
This const was not actually needed by more than one file, which simplifies how 'trainees.js' and its imported scripts are used for training.
  • Loading branch information
biancadanforth committed Aug 27, 2018
1 parent 486142b commit e3e4f15
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
3 changes: 0 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion src/extraction/fathom_extraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/extraction/ruleset_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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')),

Expand Down
11 changes: 5 additions & 6 deletions src/extraction/trainees.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* 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);
Expand All @@ -22,9 +21,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.
Expand Down

0 comments on commit e3e4f15

Please sign in to comment.