📝 Refactoring
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import { createWriteStream } from "fs";
|
|
||||||
import path from "path";
|
|
||||||
import https from "https";
|
|
||||||
import { Service, ServiceBroker, Context } from "moleculer";
|
import { Service, ServiceBroker, Context } from "moleculer";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import leven from "leven";
|
import leven from "leven";
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import { createWriteStream } from "fs";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import https from "https";
|
import https from "https";
|
||||||
import stringSimilarity from "string-similarity";
|
import stringSimilarity from "string-similarity";
|
||||||
import { each, isNil, map, isNull, isUndefined } from "lodash";
|
import { isNil, map, isUndefined } from "lodash";
|
||||||
import leven from "leven";
|
import leven from "leven";
|
||||||
|
|
||||||
const imghash = require("imghash");
|
const imghash = require("imghash");
|
||||||
@@ -100,14 +100,14 @@ const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
|
|||||||
if (!isUndefined(hash1) && !isUndefined(hash2)) {
|
if (!isUndefined(hash1) && !isUndefined(hash2)) {
|
||||||
const levenshteinDistance = leven(hash1, hash2);
|
const levenshteinDistance = leven(hash1, hash2);
|
||||||
if (levenshteinDistance === 0) {
|
if (levenshteinDistance === 0) {
|
||||||
match.score += 4;
|
match.score += 2;
|
||||||
} else if (
|
} else if (
|
||||||
levenshteinDistance > 0 &&
|
levenshteinDistance > 0 &&
|
||||||
levenshteinDistance <= 2
|
levenshteinDistance <= 2
|
||||||
) {
|
) {
|
||||||
match.score += 2;
|
match.score += 1;
|
||||||
} else {
|
} else {
|
||||||
match.score -= 4;
|
match.score -= 2;
|
||||||
}
|
}
|
||||||
resolve(match);
|
resolve(match);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user