How to use fuzzball - 7 common examples

To help you get started, we’ve selected a few fuzzball examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github r-spacex / SpaceX-API / src / scripts / upcoming.js View on Github external
let baseFlightNumber;
  if (fuzz.partial_ratio(pastLaunches[0].missionName, manifestPayloads[0]) === 100) {
    baseFlightNumber = pastLaunches[0].flight_number;
  } else {
    baseFlightNumber = pastLaunches[0].flight_number + 1;
  }

  // Compare each mission name against entire list of manifest payloads, and fuzzy match the
  // mission name against the manifest payload name. The partial match must be 100%, to avoid
  // conflicts like SSO-A and SSO-B, where a really close match would produce wrong results.
  for await (const [payloadIndex, missionName] of missionNames.entries()) {
    for await (const [manifestIndex, manifestPayload] of manifestPayloads.entries()) {
      if (fuzz.partial_ratio(missionName, manifestPayload) === 100) {
        // Special check for starlink / smallsat launches, because 'Starlink 2' and 'Starlink 23'
        // both pass the partial ratio check, so they are checked strictly below
        if (/starlink|smallsat/i.test(missionName) && fuzz.ratio(missionName, manifestPayload) !== 100) {
          // eslint-disable-next-line no-continue
          continue;
        }
        // Check and see if dates match a certain pattern depending on the length of the
        // date given. This sets the amount of precision needed for the date.
        const dateResult = await wikiManifest.checkDatePattern(manifestDates[manifestIndex].replace('-', ' ').replace('~', ''));
        const { tbd, isTentative } = dateResult;
        precision[manifestIndex] = dateResult.precision;

        // Store site_id for update query
        // Store manifest date for data cleaning
        const location = sites[payloadIndex];
        const date = manifestDates[manifestIndex];

        console.log(date);
        console.log(`${missionName} : ${manifestPayload}`);
github r-spacex / SpaceX-API / src / scripts / upcoming.js View on Github external
// Set base flight number to automatically reorder launches on the manifest
  // If the most recent past launch is still on the wiki, don't offset the flight number
  let baseFlightNumber;
  if (fuzz.partial_ratio(pastLaunches[0].missionName, manifestPayloads[0]) === 100) {
    baseFlightNumber = pastLaunches[0].flight_number;
  } else {
    baseFlightNumber = pastLaunches[0].flight_number + 1;
  }

  // Compare each mission name against entire list of manifest payloads, and fuzzy match the
  // mission name against the manifest payload name. The partial match must be 100%, to avoid
  // conflicts like SSO-A and SSO-B, where a really close match would produce wrong results.
  for await (const [payloadIndex, missionName] of missionNames.entries()) {
    for await (const [manifestIndex, manifestPayload] of manifestPayloads.entries()) {
      if (fuzz.partial_ratio(missionName, manifestPayload) === 100) {
        // Special check for starlink / smallsat launches, because 'Starlink 2' and 'Starlink 23'
        // both pass the partial ratio check, so they are checked strictly below
        if (/starlink|smallsat/i.test(missionName) && fuzz.ratio(missionName, manifestPayload) !== 100) {
          // eslint-disable-next-line no-continue
          continue;
        }
        // Check and see if dates match a certain pattern depending on the length of the
        // date given. This sets the amount of precision needed for the date.
        const dateResult = await wikiManifest.checkDatePattern(manifestDates[manifestIndex].replace('-', ' ').replace('~', ''));
        const { tbd, isTentative } = dateResult;
        precision[manifestIndex] = dateResult.precision;

        // Store site_id for update query
        // Store manifest date for data cleaning
        const location = sites[payloadIndex];
        const date = manifestDates[manifestIndex];
github r-spacex / SpaceX-API / src / scripts / upcoming.js View on Github external
// Collect site names for time zone and payload name for fuzzy check
  launches.forEach((launch) => {
    missionNames.push(launch.mission_name);
    sites.push(launch.launch_site.site_id);
    // undefined unless within threshold
    lastWikiLaunchDates.push(launch.last_wiki_launch_date);
    lastWikiDates.push(launch.last_wiki_update);
    lastWikiRevisions.push(launch.last_wiki_revision);
  });

  const { manifestDates, manifestPayloads, manifestLaunchpads } = await wikiManifest.getData();

  // Set base flight number to automatically reorder launches on the manifest
  // If the most recent past launch is still on the wiki, don't offset the flight number
  let baseFlightNumber;
  if (fuzz.partial_ratio(pastLaunches[0].missionName, manifestPayloads[0]) === 100) {
    baseFlightNumber = pastLaunches[0].flight_number;
  } else {
    baseFlightNumber = pastLaunches[0].flight_number + 1;
  }

  // Compare each mission name against entire list of manifest payloads, and fuzzy match the
  // mission name against the manifest payload name. The partial match must be 100%, to avoid
  // conflicts like SSO-A and SSO-B, where a really close match would produce wrong results.
  for await (const [payloadIndex, missionName] of missionNames.entries()) {
    for await (const [manifestIndex, manifestPayload] of manifestPayloads.entries()) {
      if (fuzz.partial_ratio(missionName, manifestPayload) === 100) {
        // Special check for starlink / smallsat launches, because 'Starlink 2' and 'Starlink 23'
        // both pass the partial ratio check, so they are checked strictly below
        if (/starlink|smallsat/i.test(missionName) && fuzz.ratio(missionName, manifestPayload) !== 100) {
          // eslint-disable-next-line no-continue
          continue;
github r-spacex / SpaceX-API / src / scripts / webcast.js View on Github external
const result = await request('https://www.spacex.com/webcast');
  const $ = cheerio.load(result);

  const embedSource = $('#content > div.left_column > font > iframe').attr('src');
  const embedName = $('#page-title').text();

  const youtubeUrl = embedSource.replace(/https:\/\/www\.youtube\.com\/embed/i, 'https://youtu.be');
  const youtubeId = youtubeUrl.replace(/https:\/\/youtu\.be\//i, '');

  const update = {
    'links.video_link': youtubeUrl,
    'links.youtube_id': youtubeId,
  };

  const ratio = fuzz.ratio(embedName.replace(/mission/i, ''), missionName.replace(/mission/i, ''));

  console.log(embedName);
  console.log(missionName);
  console.log(update);
  console.log(ratio);

  // Might need to play with this ratio, but 50% match should be good enough to
  // reasonably assume it's the correct mission. Worst case, if it doesn't pick it
  // up correctly, the data would be entered regardless, this script is purely for convenience
  if (ratio >= 50) {
    console.log('Match');
    await launch.updateOne({ upcoming: true, flight_number: flightNumber }, { $set: { 'links.video_link': youtubeUrl, 'links.youtube_id': youtubeId } });
  }

  if (client) {
    client.close();
github r-spacex / SpaceX-API / src / scripts / providers / launch-library.js View on Github external
launches.forEach((launch, index) => {
    // Fuzzy match between local name and LL name
    const partialRatio = fuzz.partial_ratio(missionName, launch.name);
    // Return best match
    if (partialRatio > bestMatch[1]) {
      bestMatch = [index, partialRatio];
    }
  });
  // Check that partial ratio is above the minimum
github nol13 / fuzzball.js / demo-app / src / components / ProductTable.js View on Github external
extract = (props) => {
        if (this.cancelToken) this.cancelToken.canceled = true;
        this.cancelToken = {canceled: false};
        const { filter, scorer, fullProcess, wildcards, dataset } = props;
        const options = {
            scorer: fuzz[scorer],
            processor: (choice) => { return choice.name; },
            full_process: fullProcess,
            wildcards,
            cancelToken: this.cancelToken
        };
        const choices = dataset;
        fuzz.extractAsPromised(filter, choices, options).then(scoredProds => {
            this.setState({scoredProds});
        }).catch(() => {
            // canceled
        });
    };
github Jyguy / Reknown / structures / client.js View on Github external
client.commandsList.forEach(cmd => {
    ordered.push([cmd, fuzz.ratio(str, cmd)]);
  });
  ordered.sort((a, b) => b[1] - a[1]);

fuzzball

Fuzzy string matching algorithms and utilities, port of the TheFuzz Python library.

MIT
Latest version published 3 months ago

Package Health Score

71 / 100
Full package analysis