hh-shipments 0.3.12 → 0.3.13
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/package.json +1 -1
- package/src/extract.js +9 -5
package/package.json
CHANGED
package/src/extract.js
CHANGED
|
@@ -64,16 +64,20 @@
|
|
|
64
64
|
}
|
|
65
65
|
// Shipping labels: the sender name is the first or second line
|
|
66
66
|
// ("MOHAMMED SALEM"). Only take it when it's clearly a name — never
|
|
67
|
-
// digits, never address fragments, never OCR garbage like "EE SS"
|
|
67
|
+
// digits, never address fragments, never OCR garbage like "EE SS",
|
|
68
|
+
// and never the app's own UI words when a screenshot of the app itself
|
|
69
|
+
// gets pasted ("Back Shipment").
|
|
68
70
|
if (!out.seller_name) {
|
|
69
71
|
var labelWords = function (s) { return String(s).trim().split(/\s+/); };
|
|
70
72
|
var looksLikeLabelName = function (s) {
|
|
71
73
|
var words = labelWords(s);
|
|
72
74
|
if (words.length < 2 || words.length > 3) return false;
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
// Real shipping labels print names in ALL CAPS; app UI chrome
|
|
76
|
+
// ("Back Shipment") and OCR fragments ("Eg NTT") don't.
|
|
77
|
+
if (s !== s.toUpperCase()) return false;
|
|
78
|
+
// every word 4+ letters: OCR garbage ("EE SS") never qualifies.
|
|
79
|
+
for (var i = 0; i < words.length; i++) if (!/^[A-Z]{4,}$/.test(words[i])) return false;
|
|
80
|
+
if (/\b(UPS|FEDEX|USPS|DHL|GROUND|EXPRESS|PRIORITY|BILLING|SHIP\b|FROM|TRACKING|POSTAGE|LABEL|BACK|SHIPMENT|HOME|ARCHIVE|SETTINGS|SCREENSHOT|READING|FINDING|UPLOADING|EXTRACT|PASTE|DETAILS|SAVE|TAP|CLIPBOARD|NUMBER)\b/.test(s)) return false;
|
|
77
81
|
return true;
|
|
78
82
|
};
|
|
79
83
|
var lines = String(text).split(/\r?\n/);
|