How to use the fuzzball.partial_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
// 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 / 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

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