const fs = require('fs'); const path = require('path'); const base_path = 'doc/curtis/prompt/scanimpl_analysis'; const inputFile = path.join(base_path, 'step1_raw_methods.json'); const outputFile = path.join(base_path, 'step2_classified_methods.json'); const rules = [ { tag: 'ScannerController', subs: [ { sub: 'twainWrapper', keywords: ['StatrTwainScan', 'OnAcquire', 'initkscan', 'CheckScannerConfig', 'PageEnd', 'PageDone', 'R_W_Scanini', 'GetDefScanIni'] } ] }, { tag: 'ImageProcessor', subs: [ { sub: 'transformer', keywords: ['DeskewImg', 'Rotate', 'CropImg', 'ImageReSize_FormID', 'ImageReSize_tmp', 'CheckNeedCrop'] }, {sub: 'converter', keywords: ['ConvertToBW', 'ConvertToGray', 'Image_Smooth', 'NegativeImg', 'CleanupBorder']}, {sub: 'barcodeRecognizer', keywords: ['MpsGetBarcode', 'Get_OMR']}, {sub: 'anchorAnalyzer', keywords: ['FindPoint', 'CheckSize', 'GetSiteOMR']} ] }, { tag: 'TransportManager', subs: [ {sub: 'requestWrapper', keywords: ['ProcessServlet', 'ProcessServlet_Get', 'ProcessServlet_FormData']}, { sub: 'fileTransfer', keywords: ['upFile', 'dnFile', 'dnFile_Get', 'GetftpInfo', 'SetFtpInfo', 'FtpCaseComplete'] }, {sub: 'utilities', keywords: ['En_DecryptionStr_Base64', 'LoadFileGetMD5', 'HTTPSClientCertificateValidate']}, {sub: 'payloadArchiver', keywords: ['ZipMainFile', 'ZipMaskFile', 'ExecuteUnZip']} ] }, { tag: 'BusinessLogic', subs: [ { sub: 'paramState', keywords: ['SetSQLData', 'GetSQLData', 'FindSQLData', 'GetSetInf1', 'GetSetInf2', 'GetSetInf3', 'GetSetInf4', 'GetSetInf5', 'GetSetInf6', 'GetSetInf7'] }, { sub: 'entityMapping', keywords: ['BarCode2FormID', 'BarCode2CaseID', 'FormCode2DocNo', 'DocNo2DocName', 'DocNoNeedDiv', 'CreateDocNo_Info', 'CreateCustDocNo_Info'] }, {sub: 'ormRuleEngine', keywords: ['OMRCheckCase', 'OMRErr2ini', 'OMRErrini2List']}, { sub: 'caseModification', keywords: ['SetUseCase', 'GetUseCase', 'OldCasetoNewCase', 'ErrFormtoCurrentForm', 'DeleteDocNoFileForESCAN'] } ] }, { tag: 'UIView', subs: [ {sub: 'treeView', keywords: ['TreeView', 'DrawDocItem2']}, {sub: 'scrollView', keywords: ['ISB', 'ImageScrollBox', 'ScrollBox']}, {sub: 'i18n', keywords: ['InitialLanguage', 'DownLanguage']}, {sub: 'layouts', keywords: ['DisplayMode', 'GoViewMode']}, {sub: 'statusMessenger', keywords: ['DataLoading', 'Timer2Timer', 'StatusBar1DblClick', 'Timer', 'StatusBar']}, {sub: 'listView', keywords: ['PageLV', 'AttListBox', 'ListView', 'ListBox']}, {sub: 'toolBar', keywords: ['BtnClick', 'FC', 'BitBtn', 'SpeedButton']}, {sub: 'popupMenu', keywords: ['PM', 'PopupMenu', 'MenuItem']} ] } ]; function classify() { const rawMethods = JSON.parse(fs.readFileSync(inputFile, 'utf8')); const classified = rawMethods.map(method => { const tags = new Set(); const lowerMatcher = method.matcher.toLowerCase(); for (const rule of rules) { for (const subRule of rule.subs) { const matched = subRule.keywords.some(k => { if (k === 'PM') return method.matcher.includes('.PM'); if (k === 'FC') return method.matcher.includes('.FC'); return lowerMatcher.includes(k.toLowerCase()); }); if (matched) { tags.add(rule.tag); tags.add(`${rule.tag}.${subRule.sub}`); } } } if (tags.size === 0) { tags.add('UIView'); tags.add('UIView.misc'); } return { matcher: method.matcher, tags: Array.from(tags), deps: [], lIndex: method.lIndex.toString(), rIndex: method.rIndex.toString(), description: "" }; }); fs.writeFileSync(outputFile, JSON.stringify(classified, null, 2), 'utf8'); console.log(`Classified ${classified.length} methods to ${outputFile}`); } classify();