@credithub/harlan-components 1.82.1 → 1.82.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/liminar/liminar.js +5 -3
- package/dist/utils/similarNames.d.ts +4 -0
- package/dist/utils/similarNames.js +72 -0
- package/lib/cjs/index.js +88 -14
- package/lib/esm/index.js +88 -14
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ import ProtestosIcon from '../../assets/icones/protestos';
|
|
|
50
50
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
51
51
|
import theme from '../../styles/theme';
|
|
52
52
|
import { formatMoney } from '../../utils/number';
|
|
53
|
-
import { normalizeName,
|
|
53
|
+
import { normalizeName, normalizeNameStrong, similarCompanyNames } from '../../utils/similarNames';
|
|
54
54
|
import { hasOneOfTags } from '../../utils/tags';
|
|
55
55
|
import { WarningCircle } from 'phosphor-react';
|
|
56
56
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -120,14 +120,15 @@ var Liminar = function (_a) {
|
|
|
120
120
|
var _a, _b, _c, _d;
|
|
121
121
|
var carouselName = (_c = (_b = (_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '';
|
|
122
122
|
var empresas = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa;
|
|
123
|
-
var
|
|
123
|
+
var nomeNormTokens = normalizeNameStrong(carouselName);
|
|
124
|
+
console.log('nomeNormTokens', nomeNormTokens);
|
|
124
125
|
if (!Array.isArray(empresas))
|
|
125
126
|
return [];
|
|
126
127
|
return empresas.filter(function (proc) {
|
|
127
128
|
var _a;
|
|
128
129
|
var ativoMatch = (_a = proc.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (e) {
|
|
129
130
|
return e.envolvido_tipo === 'Ativo' &&
|
|
130
|
-
|
|
131
|
+
similarCompanyNames(e.nome_sem_filtro, carouselName);
|
|
131
132
|
});
|
|
132
133
|
if (!ativoMatch)
|
|
133
134
|
return false;
|
|
@@ -142,6 +143,7 @@ var Liminar = function (_a) {
|
|
|
142
143
|
(_d = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _d === void 0 ? void 0 : _d.carousel,
|
|
143
144
|
(_e = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _e === void 0 ? void 0 : _e.empresa
|
|
144
145
|
]);
|
|
146
|
+
console.log('processosComAssuntoValido', processosComAssuntoValido);
|
|
145
147
|
/*
|
|
146
148
|
* Identifica as origens de liminares detectadas e verifica se existe liminar de protesto invertida
|
|
147
149
|
*/
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const normalizeName: (name: string) => string;
|
|
2
2
|
export declare const similarNames: (name1: string, name2: string, threshold?: number) => boolean;
|
|
3
3
|
export declare const similarProcessos: (name1: string, name2: string) => boolean;
|
|
4
|
+
export declare const normalizeNameStrong: (name: string) => string[];
|
|
5
|
+
export declare const tokenCoverage: (a: string[], b: string[]) => number;
|
|
6
|
+
export declare const jaccard: (a: string[], b: string[]) => number;
|
|
7
|
+
export declare const similarCompanyNames: (raw1: string, raw2: string, jaccardThr?: number, coverThr?: number, charThr?: number) => boolean;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
1
10
|
import { remove } from 'diacritics';
|
|
2
11
|
import stringSimilarity from 'string-similarity';
|
|
3
12
|
export var normalizeName = function (name) {
|
|
@@ -18,3 +27,66 @@ export var similarProcessos = function (name1, name2) {
|
|
|
18
27
|
var similarity = stringSimilarity.compareTwoStrings(name1, name2);
|
|
19
28
|
return similarity >= 0.8;
|
|
20
29
|
};
|
|
30
|
+
// palavras que quase nunca ajudam a distinguir empresas
|
|
31
|
+
var STOP_TOKENS = new Set([
|
|
32
|
+
'ltda',
|
|
33
|
+
'limitada',
|
|
34
|
+
'eireli',
|
|
35
|
+
'sa',
|
|
36
|
+
'me',
|
|
37
|
+
'ltda',
|
|
38
|
+
'empresa',
|
|
39
|
+
'sociedade',
|
|
40
|
+
'industrial',
|
|
41
|
+
'industria',
|
|
42
|
+
'industria',
|
|
43
|
+
'industries',
|
|
44
|
+
'comercio',
|
|
45
|
+
'comercial',
|
|
46
|
+
'comerc',
|
|
47
|
+
'servicos',
|
|
48
|
+
'serviço',
|
|
49
|
+
'produtos',
|
|
50
|
+
'de',
|
|
51
|
+
'da',
|
|
52
|
+
'do',
|
|
53
|
+
'dos',
|
|
54
|
+
'e'
|
|
55
|
+
]);
|
|
56
|
+
export var normalizeNameStrong = function (name) {
|
|
57
|
+
return remove(name) // tira acentos
|
|
58
|
+
.toLowerCase()
|
|
59
|
+
.replace(/[^\w\s]/g, ' ') // só letras/números
|
|
60
|
+
.split(/\s+/) // tokeniza
|
|
61
|
+
.filter(Boolean) // remove vazios
|
|
62
|
+
.filter(function (tok) { return !STOP_TOKENS.has(tok); }) // remove termos irrelevantes
|
|
63
|
+
.sort(); // deixa ordem irrelevante
|
|
64
|
+
};
|
|
65
|
+
// porcentagem do nome mais curto que aparece no mais longo
|
|
66
|
+
export var tokenCoverage = function (a, b) {
|
|
67
|
+
var _a = a.length < b.length ? [a, b] : [b, a], shorter = _a[0], longer = _a[1];
|
|
68
|
+
var inter = shorter.filter(function (t) { return longer.includes(t); }).length;
|
|
69
|
+
return shorter.length ? inter / shorter.length : 0;
|
|
70
|
+
};
|
|
71
|
+
export var jaccard = function (a, b) {
|
|
72
|
+
var setA = new Set(a);
|
|
73
|
+
var setB = new Set(b);
|
|
74
|
+
var inter = Array.from(setA).filter(function (x) { return setB.has(x); }).length;
|
|
75
|
+
var union = new Set(__spreadArray(__spreadArray([], a, true), b, true)).size;
|
|
76
|
+
return union ? inter / union : 0;
|
|
77
|
+
};
|
|
78
|
+
export var similarCompanyNames = function (raw1, raw2, jaccardThr, coverThr, charThr) {
|
|
79
|
+
if (jaccardThr === void 0) { jaccardThr = 0.7; }
|
|
80
|
+
if (coverThr === void 0) { coverThr = 0.8; }
|
|
81
|
+
if (charThr === void 0) { charThr = 0.85; }
|
|
82
|
+
var t1 = normalizeNameStrong(raw1);
|
|
83
|
+
var t2 = normalizeNameStrong(raw2);
|
|
84
|
+
// A) Jaccard sobre tokens “bons”
|
|
85
|
+
if (jaccard(t1, t2) >= jaccardThr)
|
|
86
|
+
return true;
|
|
87
|
+
// B) Cobertura total do nome mais curto
|
|
88
|
+
if (tokenCoverage(t1, t2) >= coverThr)
|
|
89
|
+
return true;
|
|
90
|
+
// C) Fallback de similaridade de caracteres
|
|
91
|
+
return (stringSimilarity.compareTwoStrings(t1.join(' '), t2.join(' ')) >= charThr);
|
|
92
|
+
};
|