curtis
17小時前 713024ccb5056e76bcfc9389664981da68a5139f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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();