<commit_before>/**
 * Copyright (c) 2019 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
 */
import {Services} from '../../build/runtime/services.js';
import {dynamicScript} from './dynamic-script.js';
import {logFactory} from '../../build/platform/log-web.js';

const log = logFactory('tfjs-service');

// TODO(sjmiles): demonstrate simple concept for tracking objects across the PEC

const references = [];
const reference = value => {
  return references.push(value) - 1;
};

const deref = reference => {
  return references[reference];
};

const dispose = reference => {
  delete references[reference];
};

// Utility

const requireTf = async () => {
  if (!window.tf) {
    await dynamicScript(`https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js`);
  }
  return window.tf;
};

// Map some TF API to a Service

const sequential = async () => {<commit_msg>use unpkg with ?module to avoid tfjs conflicting with ml5 (#3014)<commit_after>/**
 * Copyright (c) 2019 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
 */
import {Services} from '../../build/runtime/services.js';
import {dynamicScript} from './dynamic-script.js';
import {logFactory} from '../../build/platform/log-web.js';

const log = logFactory('tfjs-service');

//const tfUrl = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js`;
const tfUrl = `https://unpkg.com/@tensorflow/tfjs@1.1.2/dist/tf.min.js?module`;

// TODO(sjmiles): demonstrate simple concept for tracking objects across the PEC

const references = [];
const reference = value => {
  return references.push(value) - 1;
};

const deref = reference => {
  return references[reference];
};

const dispose = reference => {
  delete references[reference];
};

// Utility

const requireTf = async () => {
  if (!window.tf) {
    await dynamicScript(tfUrl);
  }
  return window.tf;
};

// Map some TF API to a Service

const sequential = async () => {
{'fraction_non_alphanumeric': 0.14625, 'fraction_numerical': 0.01, 'mean_word_length': 3.717092337917485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 3, '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': '1055846', 'n_tokens_mistral': 755, 'n_tokens_neox': 723, 'n_words': 230}