How to use the fuzzball.ratio function in fuzzball

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 / 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 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 1 month ago

Package Health Score

78 / 100
Full package analysis