@stevenvo780/autologic 2.0.1 → 2.2.0
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/README.md +2 -0
- package/dist/atoms/index.d.ts +1 -1
- package/dist/atoms/index.d.ts.map +1 -1
- package/dist/atoms/index.js +75 -3
- package/dist/atoms/index.js.map +1 -1
- package/dist/atoms/keyword-extractor.d.ts +9 -0
- package/dist/atoms/keyword-extractor.d.ts.map +1 -1
- package/dist/atoms/keyword-extractor.js +64 -2
- package/dist/atoms/keyword-extractor.js.map +1 -1
- package/dist/atoms/math-parser.d.ts +11 -0
- package/dist/atoms/math-parser.d.ts.map +1 -0
- package/dist/atoms/math-parser.js +44 -0
- package/dist/atoms/math-parser.js.map +1 -0
- package/dist/compiler-frontend.d.ts +9 -0
- package/dist/compiler-frontend.d.ts.map +1 -0
- package/dist/compiler-frontend.js +142 -0
- package/dist/compiler-frontend.js.map +1 -0
- package/dist/context/discourse-state.d.ts +10 -0
- package/dist/context/discourse-state.d.ts.map +1 -0
- package/dist/context/discourse-state.js +26 -0
- package/dist/context/discourse-state.js.map +1 -0
- package/dist/discourse/markers-es.d.ts.map +1 -1
- package/dist/discourse/markers-es.js +23 -0
- package/dist/discourse/markers-es.js.map +1 -1
- package/dist/discourse/pattern-detector.d.ts.map +1 -1
- package/dist/discourse/pattern-detector.js +2 -1
- package/dist/discourse/pattern-detector.js.map +1 -1
- package/dist/discourse/role-classifier.js +32 -3
- package/dist/discourse/role-classifier.js.map +1 -1
- package/dist/formalize.d.ts +16 -0
- package/dist/formalize.d.ts.map +1 -1
- package/dist/formalize.js +128 -0
- package/dist/formalize.js.map +1 -1
- package/dist/formula/argument-builder.d.ts.map +1 -1
- package/dist/formula/argument-builder.js +95 -16
- package/dist/formula/argument-builder.js.map +1 -1
- package/dist/formula/ast-compiler.d.ts +6 -0
- package/dist/formula/ast-compiler.d.ts.map +1 -0
- package/dist/formula/ast-compiler.js +105 -0
- package/dist/formula/ast-compiler.js.map +1 -0
- package/dist/formula/ast.d.ts +81 -0
- package/dist/formula/ast.d.ts.map +1 -0
- package/dist/formula/ast.js +52 -0
- package/dist/formula/ast.js.map +1 -0
- package/dist/formula/connectors.js +1 -1
- package/dist/formula/connectors.js.map +1 -1
- package/dist/formula/first-order.js +74 -7
- package/dist/formula/first-order.js.map +1 -1
- package/dist/formula/helpers.d.ts +8 -0
- package/dist/formula/helpers.d.ts.map +1 -0
- package/dist/formula/helpers.js +166 -0
- package/dist/formula/helpers.js.map +1 -0
- package/dist/formula/index.d.ts +1 -0
- package/dist/formula/index.d.ts.map +1 -1
- package/dist/formula/index.js +5 -3
- package/dist/formula/index.js.map +1 -1
- package/dist/formula/modal.d.ts.map +1 -1
- package/dist/formula/modal.js +56 -67
- package/dist/formula/modal.js.map +1 -1
- package/dist/formula/probabilistic.d.ts +3 -0
- package/dist/formula/probabilistic.d.ts.map +1 -0
- package/dist/formula/probabilistic.js +55 -0
- package/dist/formula/probabilistic.js.map +1 -0
- package/dist/formula/propositional.d.ts +2 -2
- package/dist/formula/propositional.d.ts.map +1 -1
- package/dist/formula/propositional.js +74 -102
- package/dist/formula/propositional.js.map +1 -1
- package/dist/formula/temporal.d.ts.map +1 -1
- package/dist/formula/temporal.js +87 -62
- package/dist/formula/temporal.js.map +1 -1
- package/dist/generator/validator.d.ts +20 -0
- package/dist/generator/validator.d.ts.map +1 -1
- package/dist/generator/validator.js +112 -0
- package/dist/generator/validator.js.map +1 -1
- package/dist/index.d.ts +6 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -17
- package/dist/index.js.map +1 -1
- package/dist/llm-parser.d.ts +29 -0
- package/dist/llm-parser.d.ts.map +1 -0
- package/dist/llm-parser.js +122 -0
- package/dist/llm-parser.js.map +1 -0
- package/dist/local-slm-web.d.ts +8 -0
- package/dist/local-slm-web.d.ts.map +1 -0
- package/dist/local-slm-web.js +87 -0
- package/dist/local-slm-web.js.map +1 -0
- package/dist/nl-linter/index.d.ts +10 -0
- package/dist/nl-linter/index.d.ts.map +1 -0
- package/dist/nl-linter/index.js +45 -0
- package/dist/nl-linter/index.js.map +1 -0
- package/dist/nl-linter/rules.d.ts +6 -0
- package/dist/nl-linter/rules.d.ts.map +1 -0
- package/dist/nl-linter/rules.js +93 -0
- package/dist/nl-linter/rules.js.map +1 -0
- package/dist/nl-linter/types.d.ts +14 -0
- package/dist/nl-linter/types.d.ts.map +1 -0
- package/dist/nl-linter/types.js +3 -0
- package/dist/nl-linter/types.js.map +1 -0
- package/dist/segmenter/clause-splitter.d.ts.map +1 -1
- package/dist/segmenter/clause-splitter.js +208 -10
- package/dist/segmenter/clause-splitter.js.map +1 -1
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -4
- package/readme.md +666 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTextWithLLM = parseTextWithLLM;
|
|
4
|
+
exports.llmResultToST = llmResultToST;
|
|
5
|
+
const ast_compiler_1 = require("./formula/ast-compiler");
|
|
6
|
+
const local_slm_web_1 = require("./local-slm-web");
|
|
7
|
+
/**
|
|
8
|
+
* Prompt maestro isomorfico y ciego al entorno.
|
|
9
|
+
* Instruye al LLM para actuar como un destilador proposicional situado.
|
|
10
|
+
*/
|
|
11
|
+
function buildSystemPrompt(profile) {
|
|
12
|
+
return `You are Autologic's semantic AST parser.
|
|
13
|
+
Your goal is to read complex human text (often obfuscated legal/technical jargon) and translate it into Situated Propositional Logic or bounded First-Order Logic depending on the profile: '${profile}'.
|
|
14
|
+
DO NOT try to resolve or prove the logic. Only extract the claims and their semantic relations.
|
|
15
|
+
AVOID deep First-Order combinatorial explosions. If passing a specific instance, collapse it into descriptive propositional atoms like: 'CumpleInformesOrdinarios'.
|
|
16
|
+
|
|
17
|
+
You MUST return a pure JSON object conforming exactly to this TS interface, nothing else:
|
|
18
|
+
{
|
|
19
|
+
"axioms": [ { "name": "a1", "formulaJSON": { "type": "Connective", "operator": "IMPLIES", "left": {...}, "right": {...} } } ],
|
|
20
|
+
"conclusions": [ { "formulaJSON": { "type": "Atom", "id": "PasaProgramacionEditorial" } } ]
|
|
21
|
+
}
|
|
22
|
+
Available types for formulaJSON:
|
|
23
|
+
- Atom (id)
|
|
24
|
+
- Connective (operator: AND, OR, IMPLIES, IFF, NOT, left, right)
|
|
25
|
+
- Modal (operator: K, B, O, P, BOX, DIA, etc., child, agent)
|
|
26
|
+
- Quantifier (operator: FORALL, EXISTS, variables, child)
|
|
27
|
+
- predicate (name, args: ObjectNode[])
|
|
28
|
+
|
|
29
|
+
Be precise. Do not include markdown codeblocks around the JSON.`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Llama a la API del LLM (usando fetch isomorfico) para abstraer el texto a AST.
|
|
33
|
+
*/
|
|
34
|
+
async function parseTextWithLLM(text, profile, config) {
|
|
35
|
+
const systemPrompt = buildSystemPrompt(profile);
|
|
36
|
+
if (config.provider === 'web-distilled') {
|
|
37
|
+
return await (0, local_slm_web_1.runDistilledWebInference)(text, profile, systemPrompt, config.endpoint);
|
|
38
|
+
}
|
|
39
|
+
if (config.provider === 'ollama') {
|
|
40
|
+
// Interfaz nativa de Ollama para el servidor GPU
|
|
41
|
+
const url = config.endpoint || 'http://localhost:11434/api/chat';
|
|
42
|
+
const response = await fetch(url, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: { 'Content-Type': 'application/json' },
|
|
45
|
+
body: JSON.stringify({
|
|
46
|
+
model: config.model || 'qwen2.5:7b',
|
|
47
|
+
messages: [
|
|
48
|
+
{ role: 'system', content: systemPrompt },
|
|
49
|
+
{ role: 'user', content: `Formalize this text:\n\n${text}` }
|
|
50
|
+
],
|
|
51
|
+
stream: false,
|
|
52
|
+
format: 'json',
|
|
53
|
+
options: {
|
|
54
|
+
temperature: 0.1
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
const errText = await response.text();
|
|
60
|
+
throw new Error(`Ollama API Error: ${response.status} - ${errText}`);
|
|
61
|
+
}
|
|
62
|
+
const data = await response.json();
|
|
63
|
+
const rawContent = data.message.content;
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(rawContent);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
throw new Error(`Failed to parse Ollama JSON. Raw: ${rawContent}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let url = config.endpoint || 'https://api.openai.com/v1/chat/completions';
|
|
72
|
+
let headers = {
|
|
73
|
+
'Content-Type': 'application/json'
|
|
74
|
+
};
|
|
75
|
+
let body = {};
|
|
76
|
+
if (config.provider === 'openai') {
|
|
77
|
+
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
78
|
+
body = {
|
|
79
|
+
model: config.model || 'gpt-4o',
|
|
80
|
+
messages: [
|
|
81
|
+
{ role: 'system', content: systemPrompt },
|
|
82
|
+
{ role: 'user', content: `Formalize this text:\n\n${text}` }
|
|
83
|
+
],
|
|
84
|
+
response_format: { type: 'json_object' },
|
|
85
|
+
temperature: 0.1
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new Error(`Provider ${config.provider} not yet fully implemented in this isomorphic fetch stub.`);
|
|
90
|
+
}
|
|
91
|
+
const response = await fetch(url, {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers,
|
|
94
|
+
body: JSON.stringify(body)
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
const errText = await response.text();
|
|
98
|
+
throw new Error(`LLM API Error: ${response.status} - ${errText}`);
|
|
99
|
+
}
|
|
100
|
+
const data = await response.json();
|
|
101
|
+
const rawContent = data.choices[0].message.content;
|
|
102
|
+
try {
|
|
103
|
+
return JSON.parse(rawContent);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
throw new Error(`Failed to parse LLM JSON output. Raw: ${rawContent}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Transforma la respuesta estructurada del LLM directamente a líneas de código ST seguras.
|
|
111
|
+
*/
|
|
112
|
+
function llmResultToST(result) {
|
|
113
|
+
const lines = [];
|
|
114
|
+
for (const ax of result.axioms) {
|
|
115
|
+
lines.push({ formula: (0, ast_compiler_1.compileAST)(ax.formulaJSON), type: 'axiom' });
|
|
116
|
+
}
|
|
117
|
+
for (const conc of result.conclusions) {
|
|
118
|
+
lines.push({ formula: (0, ast_compiler_1.compileAST)(conc.formulaJSON), type: 'check' });
|
|
119
|
+
}
|
|
120
|
+
return lines;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=llm-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-parser.js","sourceRoot":"","sources":["../src/llm-parser.ts"],"names":[],"mappings":";;AA8CA,4CAiFC;AAKD,sCAYC;AA/ID,yDAAoD;AAEpD,mDAA2D;AAe3D;;;GAGG;AACH,SAAS,iBAAiB,CAAC,OAAqB;IAC9C,OAAO;+LACsL,OAAO;;;;;;;;;;;;;;;;gEAgBtI,CAAC;AACjE,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAqB,EAAE,MAAiB;IAC3F,MAAM,YAAY,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEhD,IAAI,MAAM,CAAC,QAAQ,KAAK,eAAe,EAAE,CAAC;QACvC,OAAO,MAAM,IAAA,wCAAwB,EAAC,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvF,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,iDAAiD;QACjD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,IAAI,iCAAiC,CAAC;QACjE,MAAM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AACH,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAuB;IACnD,MAAM,KAAK,GAAmD,EAAE,CAAC;IAEjE,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAA,yBAAU,EAAC,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAA,yBAAU,EAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LLMParsedResult } from './llm-parser';
|
|
2
|
+
import { LogicProfile } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Loads @huggingface/transformers asynchronously and runs local ONNX inference
|
|
5
|
+
* using our fine-tuned Qwen2.5-0.5B model hosted on HuggingFace or loaded locally.
|
|
6
|
+
*/
|
|
7
|
+
export declare function runDistilledWebInference(text: string, profile: LogicProfile, systemPrompt: string, customModelUrl?: string): Promise<LLMParsedResult>;
|
|
8
|
+
//# sourceMappingURL=local-slm-web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-slm-web.d.ts","sourceRoot":"","sources":["../src/local-slm-web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA2CvC;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA2C3J"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runDistilledWebInference = runDistilledWebInference;
|
|
4
|
+
let pipeline = null;
|
|
5
|
+
const TRAINING_SYSTEM_PROMPT = `You are Autologic's semantic AST parser.
|
|
6
|
+
Your goal is to read complex human text (often obfuscated legal/technical jargon) and translate it into Situated Propositional Logic.
|
|
7
|
+
DO NOT try to resolve or prove the logic. Only extract the claims and their semantic relations.
|
|
8
|
+
AVOID deep First-Order combinatorial explosions. Collapse contextual instances into descriptive propositional atoms like: 'CumpleInformesOrdinarios'.
|
|
9
|
+
|
|
10
|
+
You MUST return a pure JSON object conforming exactly to this interface, nothing else:
|
|
11
|
+
{
|
|
12
|
+
"axioms": [ { "name": "a1", "formulaJSON": { "type": "Connective", "operator": "IMPLIES", "left": {...}, "right": {...} } } ],
|
|
13
|
+
"conclusions": [ { "formulaJSON": { "type": "Atom", "id": "X", "text": "..." } } ]
|
|
14
|
+
}
|
|
15
|
+
Available node types for formulaJSON:
|
|
16
|
+
- AtomNode: { "type": "Atom", "id": "CAMEL_CASE_ID", "text": "human readable" }
|
|
17
|
+
- ConnectiveNode: { "type": "Connective", "operator": "AND"|"OR"|"IMPLIES"|"IFF"|"NOT", "left": node, "right": node }
|
|
18
|
+
- ModalNode: { "type": "Modal", "operator": "K"|"B"|"O"|"P"|"BOX"|"DIA", "child": node }
|
|
19
|
+
- QuantifierNode: { "type": "Quantifier", "operator": "FORALL"|"EXISTS", "variables": ["x"], "child": node }
|
|
20
|
+
|
|
21
|
+
Be precise. Return ONLY the raw JSON object. No markdown, no explanation, no codeblocks.`;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts the first complete JSON object from a string,
|
|
24
|
+
* handling trailing garbage that the model may produce after the JSON.
|
|
25
|
+
*/
|
|
26
|
+
function extractFirstJSON(text) {
|
|
27
|
+
let braceCount = 0;
|
|
28
|
+
let jsonStart = -1;
|
|
29
|
+
for (let i = 0; i < text.length; i++) {
|
|
30
|
+
if (text[i] === '{') {
|
|
31
|
+
if (jsonStart === -1)
|
|
32
|
+
jsonStart = i;
|
|
33
|
+
braceCount++;
|
|
34
|
+
}
|
|
35
|
+
else if (text[i] === '}') {
|
|
36
|
+
braceCount--;
|
|
37
|
+
if (braceCount === 0 && jsonStart !== -1) {
|
|
38
|
+
return text.substring(jsonStart, i + 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return text;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Loads @huggingface/transformers asynchronously and runs local ONNX inference
|
|
46
|
+
* using our fine-tuned Qwen2.5-0.5B model hosted on HuggingFace or loaded locally.
|
|
47
|
+
*/
|
|
48
|
+
async function runDistilledWebInference(text, profile, systemPrompt, customModelUrl) {
|
|
49
|
+
if (!pipeline) {
|
|
50
|
+
try {
|
|
51
|
+
// Dynamic import for @huggingface/transformers (ESM)
|
|
52
|
+
const transformers = await Function('return import("@huggingface/transformers")')();
|
|
53
|
+
const { pipeline: trPipeline, env } = transformers;
|
|
54
|
+
env.allowLocalModels = true;
|
|
55
|
+
if (customModelUrl) {
|
|
56
|
+
env.localModelPath = customModelUrl;
|
|
57
|
+
env.allowRemoteModels = false;
|
|
58
|
+
}
|
|
59
|
+
// HuggingFace CDN model (fp32 ONNX, ~2.4GB lazy download)
|
|
60
|
+
const modelName = customModelUrl ? 'model-web' : 'stevenvo780/autologic-slm-onnx';
|
|
61
|
+
pipeline = await trPipeline('text-generation', modelName, {
|
|
62
|
+
local_files_only: !!customModelUrl,
|
|
63
|
+
dtype: 'fp32',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
throw new Error(`Web inference blocked: ${e.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Use the EXACT system prompt from training for best results
|
|
71
|
+
const prompt = `<|im_start|>system\n${TRAINING_SYSTEM_PROMPT}<|im_end|>\n<|im_start|>user\nFormalize this text:\n\n${text}<|im_end|>\n<|im_start|>assistant\n`;
|
|
72
|
+
const output = await pipeline(prompt, {
|
|
73
|
+
max_new_tokens: 512,
|
|
74
|
+
temperature: 0.1,
|
|
75
|
+
do_sample: false,
|
|
76
|
+
return_full_text: false,
|
|
77
|
+
});
|
|
78
|
+
const rawContent = output[0]?.generated_text || '';
|
|
79
|
+
try {
|
|
80
|
+
const jsonStr = extractFirstJSON(rawContent);
|
|
81
|
+
return JSON.parse(jsonStr);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
throw new Error(`Web inference JSON parse failed: ${rawContent.substring(0, 200)}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=local-slm-web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-slm-web.js","sourceRoot":"","sources":["../src/local-slm-web.ts"],"names":[],"mappings":";;AAgDA,4DA2CC;AAxFD,IAAI,QAAQ,GAAQ,IAAI,CAAC;AAEzB,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;yFAgB0D,CAAC;AAE1F;;;GAGG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACpB,IAAI,SAAS,KAAK,CAAC,CAAC;gBAAE,SAAS,GAAG,CAAC,CAAC;YACpC,UAAU,EAAE,CAAC;QACf,CAAC;aAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC3B,UAAU,E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AE;QACpC,cAAc,EAAE,GAAG;QACnB,WAAW,EAAE,GAAG;QAChB,SAAS,EAAE,KAAK;QAChB,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,cAAc,IAAI,EAAE,CAAC;IAEnD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoB,CAAC;IAChD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,oCAAoC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NLLinterDiagnostic, NLRule } from './types';
|
|
2
|
+
export declare const DEFAULT_RULES: NLRule[];
|
|
3
|
+
/**
|
|
4
|
+
* Escanea de forma asíncrona un texto buscando posibles violaciones de formalización sintiéndose como un Linter "ESLint".
|
|
5
|
+
* Totalmente compatible con ejecución en cliente.
|
|
6
|
+
*/
|
|
7
|
+
export declare function lintNaturalLanguage(text: string, rules?: NLRule[]): NLLinterDiagnostic[];
|
|
8
|
+
export * from './types';
|
|
9
|
+
export * from './rules';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nl-linter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGrD,eAAO,MAAM,aAAa,EAAE,MAAM,EAKjC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,EAAkB,GAAG,kBAAkB,EAAE,CAavG;AAED,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DEFAULT_RULES = void 0;
|
|
18
|
+
exports.lintNaturalLanguage = lintNaturalLanguage;
|
|
19
|
+
const rules_1 = require("./rules");
|
|
20
|
+
exports.DEFAULT_RULES = [
|
|
21
|
+
rules_1.anaphoricRule,
|
|
22
|
+
rules_1.cognitiveDensityRule,
|
|
23
|
+
rules_1.fuzzyQuantifiersRule,
|
|
24
|
+
rules_1.logicalCompletenessRule
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Escanea de forma asíncrona un texto buscando posibles violaciones de formalización sintiéndose como un Linter "ESLint".
|
|
28
|
+
* Totalmente compatible con ejecución en cliente.
|
|
29
|
+
*/
|
|
30
|
+
function lintNaturalLanguage(text, rules = exports.DEFAULT_RULES) {
|
|
31
|
+
if (!text || text.trim() === '')
|
|
32
|
+
return [];
|
|
33
|
+
let diagnostics = [];
|
|
34
|
+
for (const rule of rules) {
|
|
35
|
+
const result = rule.evaluate(text);
|
|
36
|
+
if (result && result.length) {
|
|
37
|
+
diagnostics = diagnostics.concat(result);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Ordenar por aparición en el texto
|
|
41
|
+
return diagnostics.sort((a, b) => a.start - b.start);
|
|
42
|
+
}
|
|
43
|
+
__exportStar(require("./types"), exports);
|
|
44
|
+
__exportStar(require("./rules"), exports);
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nl-linter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAcA,kDAaC;AA1BD,mCAA6G;AAEhG,QAAA,aAAa,GAAa;IACrC,qBAAa;IACb,4BAAoB;IACpB,4BAAoB;IACpB,+BAAuB;CACxB,CAAC;AAEF;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,IAAY,EAAE,QAAkB,qBAAa;IAC/E,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAE3C,IAAI,WAAW,GAAyB,EAAE,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAC5B,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;IACJ,CAAC;IAED,oCAAoC;IACpC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,0CAAwB;AACxB,0CAAwB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NLRule } from './types';
|
|
2
|
+
export declare const anaphoricRule: NLRule;
|
|
3
|
+
export declare const cognitiveDensityRule: NLRule;
|
|
4
|
+
export declare const fuzzyQuantifiersRule: NLRule;
|
|
5
|
+
export declare const logicalCompletenessRule: NLRule;
|
|
6
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/nl-linter/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAsB,MAAM,SAAS,CAAC;AAG1D,eAAO,MAAM,aAAa,EAAE,MAmB3B,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,MAyBlC,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,MAmBlC,CAAC;AAGF,eAAO,MAAM,uBAAuB,EAAE,MAoBrC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logicalCompletenessRule = exports.fuzzyQuantifiersRule = exports.cognitiveDensityRule = exports.anaphoricRule = void 0;
|
|
4
|
+
// 1. Ambigüedad Anafórica
|
|
5
|
+
exports.anaphoricRule = {
|
|
6
|
+
id: 'nl-anaphoric-ambiguity',
|
|
7
|
+
name: 'Ambigüedad Anafórica',
|
|
8
|
+
severity: 'warning',
|
|
9
|
+
evaluate: (text) => {
|
|
10
|
+
const diags = [];
|
|
11
|
+
const regex = /\b(este|ese|aquel|el cual|los cuales|lo anterior|su)\b/gi;
|
|
12
|
+
let match;
|
|
13
|
+
while ((match = regex.exec(text)) !== null) {
|
|
14
|
+
diags.push({
|
|
15
|
+
id: 'nl-anaphoric-ambiguity',
|
|
16
|
+
severity: 'warning',
|
|
17
|
+
message: `El pronombre anafórico '${match[1]}' puede confundir al modelo o diluir la abstracción. Si es posible, usa el sujeto explícito.`,
|
|
18
|
+
start: match.index,
|
|
19
|
+
end: match.index + match[0].length
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return diags;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
// 2. Densidad Cognitiva (Oraciones extremadamente largas)
|
|
26
|
+
exports.cognitiveDensityRule = {
|
|
27
|
+
id: 'nl-cognitive-density',
|
|
28
|
+
name: 'Densidad Cognitiva Alta',
|
|
29
|
+
severity: 'warning',
|
|
30
|
+
evaluate: (text) => {
|
|
31
|
+
const diags = [];
|
|
32
|
+
const sentences = text.split(/(?<=[.!?])\s+/);
|
|
33
|
+
let currentOffset = 0;
|
|
34
|
+
for (const sentence of sentences) {
|
|
35
|
+
const wordCount = sentence.split(/\s+/).filter(w => w.length > 0).length;
|
|
36
|
+
if (wordCount > 40) {
|
|
37
|
+
const startIndex = text.indexOf(sentence, currentOffset);
|
|
38
|
+
diags.push({
|
|
39
|
+
id: 'nl-cognitive-density',
|
|
40
|
+
severity: 'warning',
|
|
41
|
+
message: `Oración muy larga (${wordCount} palabras). El contexto semántico formal pierde precisión en oraciones kilométricas sin puntuación. Divídela.`,
|
|
42
|
+
start: startIndex >= 0 ? startIndex : currentOffset,
|
|
43
|
+
end: startIndex >= 0 ? startIndex + sentence.length : currentOffset + sentence.length
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
currentOffset += sentence.length;
|
|
47
|
+
}
|
|
48
|
+
return diags;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
// 3. Cuantificación difusa
|
|
52
|
+
exports.fuzzyQuantifiersRule = {
|
|
53
|
+
id: 'nl-fuzzy-quantifier',
|
|
54
|
+
name: 'Cuantificador Difuso',
|
|
55
|
+
severity: 'error',
|
|
56
|
+
evaluate: (text) => {
|
|
57
|
+
const diags = [];
|
|
58
|
+
const regex = /\b(frecuentemente|la mayoría de|casi nunca|a veces|probablemente|en ocasiones)\b/gi;
|
|
59
|
+
let match;
|
|
60
|
+
while ((match = regex.exec(text)) !== null) {
|
|
61
|
+
diags.push({
|
|
62
|
+
id: 'nl-fuzzy-quantifier',
|
|
63
|
+
severity: 'error',
|
|
64
|
+
message: `Término difuso '${match[1]}'. La lógica proposicional exacta requiere condicionales definidos o cuantificadores absolutos (todos, ninguno).`,
|
|
65
|
+
start: match.index,
|
|
66
|
+
end: match.index + match[0].length
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return diags;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
// 4. Completitud lógica (ausencia de conectores de inferencia en textos argumentativos)
|
|
73
|
+
exports.logicalCompletenessRule = {
|
|
74
|
+
id: 'nl-missing-relations',
|
|
75
|
+
name: 'Falta de Relaciones Estructurales',
|
|
76
|
+
severity: 'warning',
|
|
77
|
+
evaluate: (text) => {
|
|
78
|
+
const diags = [];
|
|
79
|
+
const hasConclusion = /\b(por lo tanto|en consecuencia|ergo|luego|se concluye|por ende)\b/i.test(text);
|
|
80
|
+
const hasImplication = /\b(si\s.*entonces|solo si|siempre que)\b/i.test(text);
|
|
81
|
+
if (!hasConclusion && !hasImplication && text.length > 60) {
|
|
82
|
+
diags.push({
|
|
83
|
+
id: 'nl-missing-relations',
|
|
84
|
+
severity: 'warning',
|
|
85
|
+
message: 'El texto carece de conectores lógicos evidentes (ej. "si... entonces", "por lo tanto"). ¿Deseas evaluarlo solo como premisas aisladas?',
|
|
86
|
+
start: 0,
|
|
87
|
+
end: Math.min(text.length, 60)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return diags;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/nl-linter/rules.ts"],"names":[],"mappings":";;;AAEA,0BAA0B;AACb,QAAA,aAAa,GAAW;IACnC,EAAE,EAAE,wBAAwB;IAC5B,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QACjB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nB,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QACjB,MAAM,KAAK,GAAyB,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,qEAAqE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvG,MAAM,cAAc,GAAG,2CAA2C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9E,IAAI,CAAC,aAAa,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACzD,KAAK,CAAC,IAAI,CAAC;gBACT,EAAE,EAAE,sBAAsB;gBAC1B,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,wIAAwI;gBACjJ,KAAK,EAAE,CAAC;gBACR,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;aAC/B,CAAC,CAAC;QACN,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface NLLinterDiagnostic {
|
|
2
|
+
id: string;
|
|
3
|
+
severity: 'warning' | 'error';
|
|
4
|
+
message: string;
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
export interface NLRule {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
severity: 'warning' | 'error';
|
|
12
|
+
evaluate: (text: string) => NLLinterDiagnostic[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/nl-linter/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC;IAC9B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,kBAAkB,EAAE,CAAC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/nl-linter/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clause-splitter.d.ts","sourceRoot":"","sources":["../../src/segmenter/clause-splitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAkB,QAAQ,EAAc,MAAM,UAAU,CAAC;AAW7E;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAe,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"clause-splitter.d.ts","sourceRoot":"","sources":["../../src/segmenter/clause-splitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAkB,QAAQ,EAAc,MAAM,UAAU,CAAC;AAW7E;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAe,GAAG,MAAM,EAAE,CA8ElF"}
|