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

Commit

Permalink
Merge pull request #275 from erikrose/90%-price
Browse files Browse the repository at this point in the history
92% price accuracy
  • Loading branch information
Osmose authored Nov 20, 2018
2 parents 836dfaa + 3c6649a commit ffa8242
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 173 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"dependencies": {
"autobind-decorator": "2.1.0",
"dinero.js": "1.4.0",
"fathom-web": "2.3.0",
"fathom-web": "2.8.0",
"lodash.maxby": "4.6.0",
"lodash.minby": "4.6.0",
"lodash.orderby": "^4.6.0",
Expand Down
22 changes: 13 additions & 9 deletions src/extraction/fathom/coefficients.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"hasDollarSignCoeff": 8,
"hasPriceInClassNameCoeff": 2,
"hasPriceInIDCoeff": 17,
"hasPriceishPatternCoeff": 15,
"isAboveTheFoldImageCoeff": 13,
"isAboveTheFoldPriceCoeff": 33,
"isNearbyImageXAxisPriceCoeff": 5,
"backgroundIdImageCoeff": 4,
"bigFontCoeff": 14,
"bigImageCoeff": 9,
"extremeAspectCoeff": 3,
"hasDollarSignCoeff": 3,
"hasPriceInClassNameCoeff": 7,
"hasPriceInIDCoeff": 8,
"hasPriceInParentClassNameCoeff": -1,
"hasPriceInParentIDCoeff": -2,
"hasPriceishPatternCoeff": 4,
"isAboveTheFoldImageCoeff": 5,
"isAboveTheFoldPriceCoeff": -19,
"isNearbyImageYAxisTitleCoeff": 5,
"largerFontSizeCoeff": 7,
"largerImageCoeff": 2
"isNearImageCoeff": 4
}
17 changes: 16 additions & 1 deletion src/extraction/fathom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,23 @@ const FEATURE_DEFAULTS = {
const PRODUCT_FEATURES = {
image: {
...FEATURE_DEFAULTS,
/**
* @return the URL of an image resource
*/
getValueFromElement(element) {
return element.src;
/**
* Given a CSS url() declaration 'url("http://foo")', return 'http://foo'.
*/
function urlFromCssDeclaration(declaration) {
return declaration.slice(5, -2);
}

if (element.tagName === 'IMG') {
return element.src;
}
// The other thing the ruleset can return is an arbitrary element with
// a CSS background image.
return urlFromCssDeclaration(getComputedStyle(element)['background-image']);
},
},
title: {
Expand Down
Loading

0 comments on commit ffa8242

Please sign in to comment.