@signaliz/cli 1.0.79 → 1.0.80
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/bin.js +34 -14
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -236,27 +236,47 @@ function firstValidSignalValue(values, normalize) {
|
|
|
236
236
|
}
|
|
237
237
|
return "";
|
|
238
238
|
}
|
|
239
|
+
function publicSignalSummary(value, title) {
|
|
240
|
+
if (!value) return "";
|
|
241
|
+
const severePageChrome = /\[share\]\(mailto:|\blast modified on\b|\bprefer the guardian on google\b/i.test(value);
|
|
242
|
+
let cleaned = value.replace(/\[(?:share|email)\]\((?:mailto:|https?:\/\/)[^)]+\)/gi, " ").replace(/\bskip to content\b[\s\S]*$/i, " ").replace(/\b(?:explore stocks|trading disclosure)\b[\s\S]*$/i, " ").replace(/\bimage by:\s*([A-Z][A-Za-z0-9.&'-]*)\s+\1\b/gi, "$1").replace(/\bimage by:\s*[^.!?]{1,80}(?=[.!?]|$)/gi, " ").replace(/[^.!?]{0,100}\b(?:logo|image|photo)\b[^.!?]{0,100}[.!?]\s*\((?:Reuters|AP)\)\s*/gi, " ").replace(/(?:(?:read\s*post|read\s*more|keep\s*reading|learn\s*more)\s*)+/gi, " ").replace(/\b(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?:y)?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)\s+\d{1,2},\s+\d{4}\b/gi, " ").replace(/\s*\.{3,}\s*/g, " ").replace(/\s+/g, " ").replace(/\s+([,.!?])/g, "$1").trim();
|
|
243
|
+
const sentenceEnds = Array.from(cleaned.matchAll(/[.!?](?=\s+[A-Z]|$)/g));
|
|
244
|
+
const lastSentenceEnd = sentenceEnds[sentenceEnds.length - 1]?.index ?? -1;
|
|
245
|
+
if (cleaned.length > 240 && lastSentenceEnd >= 100 && cleaned.length - lastSentenceEnd > 20) {
|
|
246
|
+
cleaned = cleaned.slice(0, lastSentenceEnd + 1);
|
|
247
|
+
}
|
|
248
|
+
const metadataAfterTitle = /\b(?:\d+\s+min(?:ute)?s?\s+read|news\s+\d+\s+mins?)\b/i.test(cleaned);
|
|
249
|
+
if (title && cleaned.toLowerCase().startsWith(title.toLowerCase())) {
|
|
250
|
+
const remainder = cleaned.slice(title.length).replace(/^\s*(?:[:|\-–—]\s*)?/, "");
|
|
251
|
+
if (/^(?:[A-Z]|news\b)/.test(remainder)) cleaned = remainder;
|
|
252
|
+
}
|
|
253
|
+
const key = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
254
|
+
const cleanedKey = key(cleaned);
|
|
255
|
+
const titleKey = key(title);
|
|
256
|
+
return severePageChrome || metadataAfterTitle || !cleaned || /^(?:api)$/i.test(cleaned) || titleKey && (cleanedKey === titleKey || cleanedKey === `${titleKey} ${titleKey}`) ? title : cleaned;
|
|
257
|
+
}
|
|
239
258
|
function publicSignalRow(value, fallbackCompany) {
|
|
240
259
|
const signal = record(value);
|
|
241
260
|
const raw = record(signal.raw_data);
|
|
242
261
|
const company = record(signal.company);
|
|
243
262
|
const rawCompany = record(raw.company);
|
|
244
263
|
const fallback = record(fallbackCompany);
|
|
264
|
+
const signalTitle = firstValidSignalValue([
|
|
265
|
+
signal.signal_title,
|
|
266
|
+
signal.signalTitle,
|
|
267
|
+
raw.signal_title,
|
|
268
|
+
raw.signalTitle,
|
|
269
|
+
signal.title,
|
|
270
|
+
raw.title,
|
|
271
|
+
signal.headline,
|
|
272
|
+
raw.headline,
|
|
273
|
+
signal.name,
|
|
274
|
+
raw.name
|
|
275
|
+
], signalText);
|
|
245
276
|
const row = {
|
|
246
277
|
signal_type: publicSignalType(signal),
|
|
247
|
-
signal_title:
|
|
248
|
-
|
|
249
|
-
signal.signalTitle,
|
|
250
|
-
raw.signal_title,
|
|
251
|
-
raw.signalTitle,
|
|
252
|
-
signal.title,
|
|
253
|
-
raw.title,
|
|
254
|
-
signal.headline,
|
|
255
|
-
raw.headline,
|
|
256
|
-
signal.name,
|
|
257
|
-
raw.name
|
|
258
|
-
], signalText),
|
|
259
|
-
signal_summary: firstValidSignalValue([
|
|
278
|
+
signal_title: signalTitle,
|
|
279
|
+
signal_summary: publicSignalSummary(firstValidSignalValue([
|
|
260
280
|
signal.signal_summary,
|
|
261
281
|
signal.signalSummary,
|
|
262
282
|
raw.signal_summary,
|
|
@@ -271,7 +291,7 @@ function publicSignalRow(value, fallbackCompany) {
|
|
|
271
291
|
raw.content,
|
|
272
292
|
signal.description,
|
|
273
293
|
raw.description
|
|
274
|
-
], signalText),
|
|
294
|
+
], signalText), signalTitle),
|
|
275
295
|
source: firstValidSignalValue([
|
|
276
296
|
signal.canonical_source_url,
|
|
277
297
|
signal.canonicalSourceUrl,
|
package/package.json
CHANGED