debug: add detailed logging to extractSkills function
Add verbose debug logging to trace why Skills section extraction is failing. Logs added: - Whether statsText is provided - Text length and if it contains 'Skills:' - Whether main regex matched - If 'On Person:' exists (lookahead target) - 200 chars of text around Skills section - Whether simple format fallback matched - Captured text length when successful This will help diagnose why parser logs show 'Skills extraction failed' even when Skills section clearly exists in the text. Related: Skills categorization issue investigation
This commit is contained in:
@@ -147,23 +147,37 @@ function debugLog(message, data = null) {
|
|||||||
* @returns {Object|null} Structured skills data or null if not found
|
* @returns {Object|null} Structured skills data or null if not found
|
||||||
*/
|
*/
|
||||||
function extractSkills(statsText) {
|
function extractSkills(statsText) {
|
||||||
if (!statsText) return null;
|
if (!statsText) {
|
||||||
|
debugLog('[RPG Parser] extractSkills: No stats text provided');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
debugLog('[RPG Parser] extractSkills: Searching for Skills section in text length:', statsText.length);
|
||||||
|
debugLog('[RPG Parser] extractSkills: Text contains "Skills:":', statsText.includes('Skills:'));
|
||||||
|
|
||||||
// Find the Skills section
|
// Find the Skills section
|
||||||
const skillsMatch = statsText.match(/Skills:([\s\S]*?)(?=\n\n|On Person:|Stored|Assets:|Main Quest|Optional Quest|$)/i);
|
const skillsMatch = statsText.match(/Skills:([\s\S]*?)(?=\n\n|On Person:|Stored|Assets:|Main Quest|Optional Quest|$)/i);
|
||||||
if (!skillsMatch) {
|
if (!skillsMatch) {
|
||||||
|
debugLog('[RPG Parser] extractSkills: Main regex did not match');
|
||||||
|
debugLog('[RPG Parser] extractSkills: Checking if "On Person:" exists:', statsText.includes('On Person:'));
|
||||||
|
debugLog('[RPG Parser] extractSkills: Text around Skills:', statsText.substring(statsText.indexOf('Skills:'), statsText.indexOf('Skills:') + 200));
|
||||||
|
|
||||||
// Fallback: try simple format "Skills: skill1, skill2"
|
// Fallback: try simple format "Skills: skill1, skill2"
|
||||||
const simpleMatch = statsText.match(/Skills:\s*(.+)/i);
|
const simpleMatch = statsText.match(/Skills:\s*(.+)/i);
|
||||||
if (simpleMatch) {
|
if (simpleMatch) {
|
||||||
const skillsText = simpleMatch[1].trim();
|
const skillsText = simpleMatch[1].trim();
|
||||||
|
debugLog('[RPG Parser] extractSkills: Simple format matched:', skillsText);
|
||||||
if (skillsText && skillsText !== 'None') {
|
if (skillsText && skillsText !== 'None') {
|
||||||
// Return as string for backward compatibility
|
// Return as string for backward compatibility
|
||||||
return skillsText;
|
return skillsText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debugLog('[RPG Parser] extractSkills: No Skills section found');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugLog('[RPG Parser] extractSkills: Main regex matched, captured length:', skillsMatch[1].length);
|
||||||
|
|
||||||
const skillsSection = skillsMatch[1];
|
const skillsSection = skillsMatch[1];
|
||||||
const skillsData = {
|
const skillsData = {
|
||||||
version: 1,
|
version: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user