<commit_before>// @license
// Copyright (c) 2017 Google Inc. All rights reserved.
// This code may only be used under the BSD style license found at
// http://polymer.github.io/LICENSE.txt
// Code distributed by Google as part of this project is also
// subject to an additional IP rights grant found at
// http://polymer.github.io/PATENTS.txt

"use strict";

defineParticle(({Particle}) => {
  return class ProductsFromWebPages extends Particle {
    setViews(views) {
      this.on(views, 'list', 'change', e => {
        let webPagesInput = views.get('list');
        var productsOutput = views.get('products');

        webPagesInput.toList().then(function(input) {

          for (let c of input) {
            let ei = new productsOutput.entityClass({
                'image': c['image'],
                'name': c['name']
            });
            productsOutput.store(ei);
          }

          console.log('ProductsFromWebPages converted '+input.length+
            ' WebPages to Products',
            productsOutput);
        });
      });
    }
  }
});<commit_msg>only transform WebPages including Products into Products This translation is lame at this point, but shows where this might go.<commit_after>// @license
// Copyright (c) 2017 Google Inc. All rights reserved.
// This code may only be used under the BSD style license found at
// http://polymer.github.io/LICENSE.txt
// Code distributed by Google as part of this project is also
// subject to an additional IP rights grant found at
// http://polymer.github.io/PATENTS.txt

"use strict";

defineParticle(({Particle}) => {
  return class ProductsFromWebPages extends Particle {
    setViews(views) {
      this.on(views, 'list', 'change', e => {
        let webPagesInput = views.get('list');
        var productsOutput = views.get('products');

        webPagesInput.toList().then(function(input) {

          for (let c of input) {
            let url = c['url'];

            /* Skip sites that we don't know contain Products, or that include
             * schema.org markup as we'll have picked those up already. */
            if (! url.includes('amazon')) {
              continue;
            }

            let ei = new productsOutput.entityClass({
                'image': c['image'],
                'name': c['name']
            });
            productsOutput.store(ei);
          }

          console.log('ProductsFromWebPages converted '+input.length+
            ' WebPages to Products',
            productsOutput);
        });
      });
    }
  }
});
{'fraction_non_alphanumeric': 0.11998426435877262, 'fraction_numerical': 0.003147128245476003, 'mean_word_length': 2.1947236180904524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '531974', 'n_tokens_mistral': 690, 'n_tokens_neox': 651, 'n_words': 217}