cnhkmcp 1.3.6__py3-none-any.whl → 1.3.8__py3-none-any.whl

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.
Files changed (57) hide show
  1. cnhkmcp/__init__.py +1 -1
  2. cnhkmcp/untracked/APP/.gitignore +32 -0
  3. cnhkmcp/untracked/APP/MODULAR_STRUCTURE.md +123 -0
  4. cnhkmcp/untracked/APP/README.md +309 -0
  5. cnhkmcp/untracked/APP/__pycache__/app.cpython-313.pyc +0 -0
  6. cnhkmcp/untracked/APP/blueprints/__init__.py +5 -0
  7. cnhkmcp/untracked/APP/blueprints/__pycache__/__init__.cpython-313.pyc +0 -0
  8. cnhkmcp/untracked/APP/blueprints/__pycache__/feature_engineering.cpython-313.pyc +0 -0
  9. cnhkmcp/untracked/APP/blueprints/__pycache__/idea_house.cpython-313.pyc +0 -0
  10. cnhkmcp/untracked/APP/blueprints/__pycache__/inspiration_house.cpython-313.pyc +0 -0
  11. cnhkmcp/untracked/APP/blueprints/__pycache__/paper_analysis.cpython-313.pyc +0 -0
  12. cnhkmcp/untracked/APP/blueprints/__pycache__/simulator.cpython-313.pyc +0 -0
  13. cnhkmcp/untracked/APP/blueprints/__pycache__/unified_tools.cpython-313.pyc +0 -0
  14. cnhkmcp/untracked/APP/blueprints/__pycache__/wqb_simulator.cpython-313.pyc +0 -0
  15. cnhkmcp/untracked/APP/blueprints/feature_engineering.py +347 -0
  16. cnhkmcp/untracked/APP/blueprints/idea_house.py +221 -0
  17. cnhkmcp/untracked/APP/blueprints/inspiration_house.py +432 -0
  18. cnhkmcp/untracked/APP/blueprints/paper_analysis.py +570 -0
  19. cnhkmcp/untracked/APP/custom_templates/templates.json +4582 -0
  20. cnhkmcp/untracked/APP/hkSimulator/ace_lib.py +1476 -0
  21. cnhkmcp/untracked/APP/hkSimulator/autosimulator.py +378 -0
  22. cnhkmcp/untracked/APP/hkSimulator/helpful_functions.py +180 -0
  23. cnhkmcp/untracked/APP/mirror_config.txt +20 -0
  24. cnhkmcp/untracked/APP/operaters.csv +129 -0
  25. cnhkmcp/untracked/APP/requirements.txt +44 -0
  26. cnhkmcp/untracked/APP/run_app.bat +28 -0
  27. cnhkmcp/untracked/APP/run_app.sh +34 -0
  28. cnhkmcp/untracked/APP/setup_tsinghua.bat +39 -0
  29. cnhkmcp/untracked/APP/setup_tsinghua.sh +43 -0
  30. cnhkmcp/untracked/APP/simulator/__pycache__/simulator_wqb.cpython-313.pyc +0 -0
  31. cnhkmcp/untracked/APP/simulator/alpha_submitter.py +366 -0
  32. cnhkmcp/untracked/APP/simulator/simulator_wqb.py +602 -0
  33. cnhkmcp/untracked/APP/ssrn-3332513.pdf +109188 -19
  34. cnhkmcp/untracked/APP/static/brain.js +478 -0
  35. cnhkmcp/untracked/APP/static/decoder.js +1275 -0
  36. cnhkmcp/untracked/APP/static/feature_engineering.js +1729 -0
  37. cnhkmcp/untracked/APP/static/idea_house.js +937 -0
  38. cnhkmcp/untracked/APP/static/inspiration_house.js +868 -0
  39. cnhkmcp/untracked/APP/static/paper_analysis.js +390 -0
  40. cnhkmcp/untracked/APP/static/script.js +2577 -0
  41. cnhkmcp/untracked/APP/static/simulator.js +597 -0
  42. cnhkmcp/untracked/APP/static/styles.css +3099 -0
  43. cnhkmcp/untracked/APP/templates/feature_engineering.html +959 -0
  44. cnhkmcp/untracked/APP/templates/idea_house.html +563 -0
  45. cnhkmcp/untracked/APP/templates/index.html +769 -0
  46. cnhkmcp/untracked/APP/templates/inspiration_house.html +860 -0
  47. cnhkmcp/untracked/APP/templates/paper_analysis.html +90 -0
  48. cnhkmcp/untracked/APP/templates/simulator.html +342 -0
  49. cnhkmcp/untracked/APP//321/210/342/224/220/320/240/321/210/320/261/320/234/321/206/320/231/320/243/321/205/342/225/235/320/220/321/206/320/230/320/241.py +1489 -0
  50. {cnhkmcp-1.3.6.dist-info → cnhkmcp-1.3.8.dist-info}/METADATA +1 -1
  51. cnhkmcp-1.3.8.dist-info/RECORD +67 -0
  52. cnhkmcp/untracked/APP.zip +0 -0
  53. cnhkmcp-1.3.6.dist-info/RECORD +0 -20
  54. {cnhkmcp-1.3.6.dist-info → cnhkmcp-1.3.8.dist-info}/WHEEL +0 -0
  55. {cnhkmcp-1.3.6.dist-info → cnhkmcp-1.3.8.dist-info}/entry_points.txt +0 -0
  56. {cnhkmcp-1.3.6.dist-info → cnhkmcp-1.3.8.dist-info}/licenses/LICENSE +0 -0
  57. {cnhkmcp-1.3.6.dist-info → cnhkmcp-1.3.8.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,390 @@
1
+ // Paper Analysis JavaScript
2
+
3
+ // Store API key in session storage
4
+ let apiKey = sessionStorage.getItem('deepseekApiKey');
5
+
6
+ // DOM Elements
7
+ const apiKeyInput = document.getElementById('apiKey');
8
+ const saveApiKeyBtn = document.getElementById('saveApiKey');
9
+ const fileInput = document.getElementById('paperFile');
10
+ const fileInfo = document.getElementById('fileInfo');
11
+ const analyzeBtn = document.getElementById('analyzePaper');
12
+ const resultsSection = document.querySelector('.results-section');
13
+ const tabButtons = document.querySelectorAll('.tab-btn');
14
+ const tabPanes = document.querySelectorAll('.tab-pane');
15
+ const exportBtn = document.getElementById('exportResults');
16
+
17
+ // Initialize API key if exists
18
+ if (apiKey) {
19
+ apiKeyInput.value = apiKey;
20
+ }
21
+
22
+ // Save API Key and Test Connection
23
+ saveApiKeyBtn.addEventListener('click', async () => {
24
+ const newApiKey = apiKeyInput.value.trim();
25
+ if (!newApiKey) {
26
+ showNotification('Please enter a valid API key', 'error');
27
+ return;
28
+ }
29
+
30
+ try {
31
+ showLoading('Testing API connection...');
32
+
33
+ const response = await fetch('/paper-analysis/api/test-deepseek', {
34
+ method: 'POST',
35
+ headers: {
36
+ 'X-API-Key': newApiKey,
37
+ 'Content-Type': 'application/json'
38
+ }
39
+ });
40
+
41
+ const data = await response.json();
42
+
43
+ if (response.ok && data.success) {
44
+ sessionStorage.setItem('deepseekApiKey', newApiKey);
45
+ apiKey = newApiKey;
46
+ showNotification('API connection successful', 'success');
47
+ } else {
48
+ showNotification(`API Error: ${data.error || 'Unknown error'}`, 'error');
49
+ console.error('API Error Details:', data);
50
+ }
51
+ } catch (error) {
52
+ showNotification('Error testing API connection: ' + error.message, 'error');
53
+ console.error('API Test Error:', error);
54
+ } finally {
55
+ hideLoading();
56
+ }
57
+ });
58
+
59
+ // File Upload Handling
60
+ fileInput.addEventListener('change', handleFileSelect);
61
+ document.querySelector('.file-upload-container').addEventListener('dragover', handleDragOver);
62
+ document.querySelector('.file-upload-container').addEventListener('drop', handleFileDrop);
63
+
64
+ function handleFileSelect(event) {
65
+ const file = event.target.files[0];
66
+ if (file) {
67
+ updateFileInfo(file);
68
+ }
69
+ }
70
+
71
+ function handleDragOver(event) {
72
+ event.preventDefault();
73
+ event.stopPropagation();
74
+ event.currentTarget.classList.add('drag-over');
75
+ }
76
+
77
+ function handleFileDrop(event) {
78
+ event.preventDefault();
79
+ event.stopPropagation();
80
+ event.currentTarget.classList.remove('drag-over');
81
+
82
+ const file = event.dataTransfer.files[0];
83
+ if (file) {
84
+ fileInput.files = event.dataTransfer.files;
85
+ updateFileInfo(file);
86
+ }
87
+ }
88
+
89
+ function updateFileInfo(file) {
90
+ const sizeInMB = (file.size / (1024 * 1024)).toFixed(2);
91
+ fileInfo.innerHTML = `
92
+ <strong>File:</strong> ${file.name}<br>
93
+ <strong>Size:</strong> ${sizeInMB} MB<br>
94
+ <strong>Type:</strong> ${file.type || 'Unknown'}
95
+ `;
96
+ }
97
+
98
+ // Tab Navigation
99
+ tabButtons.forEach(button => {
100
+ button.addEventListener('click', () => {
101
+ const tabName = button.getAttribute('data-tab');
102
+
103
+ // Update active states
104
+ tabButtons.forEach(btn => btn.classList.remove('active'));
105
+ tabPanes.forEach(pane => pane.classList.remove('active'));
106
+
107
+ button.classList.add('active');
108
+ document.getElementById(`${tabName}Tab`).classList.add('active');
109
+ });
110
+ });
111
+
112
+ // Paper Analysis
113
+ analyzeBtn.addEventListener('click', async () => {
114
+ if (!apiKey) {
115
+ showNotification('Please configure your Deepseek API key first', 'error');
116
+ return;
117
+ }
118
+
119
+ if (!fileInput.files[0]) {
120
+ showNotification('Please select a file to analyze', 'error');
121
+ return;
122
+ }
123
+
124
+ const formData = new FormData();
125
+ formData.append('file', fileInput.files[0]);
126
+ formData.append('extract_keywords', document.getElementById('extractKeywords').checked);
127
+ formData.append('generate_summary', document.getElementById('generateSummary').checked);
128
+ formData.append('find_related', document.getElementById('findRelatedWorks').checked);
129
+
130
+ try {
131
+ showLoading('Analyzing paper...');
132
+
133
+ const response = await fetch('/paper-analysis/api/analyze-paper', {
134
+ method: 'POST',
135
+ headers: {
136
+ 'X-API-Key': apiKey
137
+ },
138
+ body: formData
139
+ });
140
+
141
+ const responseData = await response.json();
142
+
143
+ if (!response.ok) {
144
+ // Show detailed error message
145
+ const errorMessage = responseData.error || `HTTP error! status: ${response.status}`;
146
+ throw new Error(errorMessage);
147
+ }
148
+
149
+ displayResults(responseData);
150
+ hideLoading();
151
+ resultsSection.style.display = 'block';
152
+ showNotification('Analysis completed successfully', 'success');
153
+ } catch (error) {
154
+ hideLoading();
155
+ console.error('Analysis error:', error);
156
+ showNotification('Error analyzing paper: ' + error.message, 'error');
157
+ }
158
+ });
159
+
160
+ // Display Results
161
+ function displayResults(results) {
162
+ // Display Keywords
163
+ const keywordsContainer = document.querySelector('.keywords-container');
164
+ if (results.keywords) {
165
+ keywordsContainer.innerHTML = results.keywords.map(keyword =>
166
+ `<div class="keyword-item">
167
+ <span class="keyword-text">${keyword.text}</span>
168
+ <span class="keyword-score">${(keyword.score * 100).toFixed(1)}%</span>
169
+ </div>`
170
+ ).join('');
171
+ }
172
+
173
+ // Display Summary
174
+ const summaryContainer = document.querySelector('.summary-container');
175
+ if (results.summary) {
176
+ summaryContainer.innerHTML = `<div class="summary-text">${results.summary}</div>`;
177
+ }
178
+
179
+ // Display Related Works
180
+ const relatedContainer = document.querySelector('.related-works-container');
181
+ if (results.related_works) {
182
+ // Add MathJax script if not already loaded
183
+ if (!window.MathJax) {
184
+ const script = document.createElement('script');
185
+ script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
186
+ script.async = true;
187
+ document.head.appendChild(script);
188
+
189
+ window.MathJax = {
190
+ tex: {
191
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
192
+ displayMath: [['$$', '$$'], ['\\[', '\\]']]
193
+ }
194
+ };
195
+ }
196
+
197
+ // Display formulas
198
+ relatedContainer.innerHTML = results.related_works.map((formula, index) => {
199
+ // Determine the formula display based on type
200
+ let formulaDisplay = formula.formula;
201
+
202
+ // Wrap formula in appropriate delimiters for MathJax
203
+ if (!formulaDisplay.includes('$') && !formulaDisplay.includes('\\[') && !formulaDisplay.includes('\\(')) {
204
+ // If no delimiters, add them
205
+ if (formula.type === 'definition' || formula.type === 'theorem' || formula.importance > 0.7) {
206
+ formulaDisplay = `\\[${formulaDisplay}\\]`; // Display math for important formulas
207
+ } else {
208
+ formulaDisplay = `\\(${formulaDisplay}\\)`; // Inline math for others
209
+ }
210
+ }
211
+
212
+ // Ensure variables is properly formatted for display
213
+ let variablesDisplay = '';
214
+ if (formula.variables) {
215
+ let englishVariables = '';
216
+ let chineseVariables = '';
217
+
218
+ // Handle English variables
219
+ if (typeof formula.variables === 'string') {
220
+ try {
221
+ const variablesObj = JSON.parse(formula.variables);
222
+ englishVariables = Object.entries(variablesObj)
223
+ .map(([symbol, description]) => {
224
+ // Wrap mathematical symbols in LaTeX delimiters
225
+ const mathSymbol = `\\(${symbol}\\)`;
226
+ return `<div class="variable-item"><span class="variable-symbol">${mathSymbol}</span><span class="variable-separator">:</span><span class="variable-desc">${description}</span></div>`;
227
+ })
228
+ .join('');
229
+ } catch (e) {
230
+ englishVariables = `<div class="variable-item">${formula.variables}</div>`;
231
+ }
232
+ } else if (typeof formula.variables === 'object') {
233
+ englishVariables = Object.entries(formula.variables)
234
+ .map(([symbol, description]) => {
235
+ // Wrap mathematical symbols in LaTeX delimiters
236
+ const mathSymbol = `\\(${symbol}\\)`;
237
+ return `<div class="variable-item"><span class="variable-symbol">${mathSymbol}</span><span class="variable-separator">:</span><span class="variable-desc">${description}</span></div>`;
238
+ })
239
+ .join('');
240
+ } else {
241
+ englishVariables = `<div class="variable-item">${String(formula.variables)}</div>`;
242
+ }
243
+
244
+ // Handle Chinese variables if available
245
+ if (formula.variables_chinese) {
246
+ if (typeof formula.variables_chinese === 'string') {
247
+ try {
248
+ const variablesChineseObj = JSON.parse(formula.variables_chinese);
249
+ chineseVariables = Object.entries(variablesChineseObj)
250
+ .map(([symbol, description]) => {
251
+ // Wrap mathematical symbols in LaTeX delimiters
252
+ const mathSymbol = `\\(${symbol}\\)`;
253
+ return `<div class="variable-item"><span class="variable-symbol">${mathSymbol}</span><span class="variable-separator">:</span><span class="variable-desc">${description}</span></div>`;
254
+ })
255
+ .join('');
256
+ } catch (e) {
257
+ chineseVariables = `<div class="variable-item">${formula.variables_chinese}</div>`;
258
+ }
259
+ } else if (typeof formula.variables_chinese === 'object') {
260
+ chineseVariables = Object.entries(formula.variables_chinese)
261
+ .map(([symbol, description]) => {
262
+ // Wrap mathematical symbols in LaTeX delimiters
263
+ const mathSymbol = `\\(${symbol}\\)`;
264
+ return `<div class="variable-item"><span class="variable-symbol">${mathSymbol}</span><span class="variable-separator">:</span><span class="variable-desc">${description}</span></div>`;
265
+ })
266
+ .join('');
267
+ }
268
+ }
269
+
270
+ if (chineseVariables) {
271
+ variablesDisplay = `
272
+ <div class="variables-tabs">
273
+ <button class="var-tab-btn active" onclick="switchVariableTab(this, 'english')">English</button>
274
+ <button class="var-tab-btn" onclick="switchVariableTab(this, 'chinese')">中文</button>
275
+ </div>
276
+ <div class="variables-content">
277
+ <div class="variables-list english-vars active">${englishVariables}</div>
278
+ <div class="variables-list chinese-vars">${chineseVariables}</div>
279
+ </div>`;
280
+ } else {
281
+ variablesDisplay = `<div class="variables-list">${englishVariables}</div>`;
282
+ }
283
+ }
284
+
285
+ return `<div class="formula-item">
286
+ <div class="formula-header">
287
+ <span class="formula-number">#${index + 1}</span>
288
+ <span class="formula-type ${formula.type}">${formula.type.toUpperCase()}</span>
289
+ </div>
290
+ <div class="formula-expression">${formulaDisplay}</div>
291
+ <div class="formula-description">${formula.description}</div>
292
+ ${variablesDisplay ? `<div class="formula-variables"><strong>Variables:</strong><div class="variables-list">${variablesDisplay}</div></div>` : ''}
293
+ <div class="formula-context"><strong>Context:</strong> ${formula.context}</div>
294
+ <div class="formula-chinese"><strong>中文描述:</strong> ${formula.chinese_description || formula.Chinese_description || 'No Chinese description'}</div>
295
+ </div>`;
296
+ }).join('');
297
+
298
+ // Trigger MathJax to process the formulas
299
+ if (window.MathJax && window.MathJax.typesetPromise) {
300
+ window.MathJax.typesetPromise([relatedContainer]).catch((e) => console.error(e));
301
+ }
302
+ }
303
+ }
304
+
305
+ // Export Results
306
+ exportBtn.addEventListener('click', () => {
307
+ const results = {
308
+ keywords: Array.from(document.querySelectorAll('.keyword-item')).map(item => ({
309
+ text: item.querySelector('.keyword-text').textContent,
310
+ score: parseFloat(item.querySelector('.keyword-score').textContent) / 100
311
+ })),
312
+ summary: document.querySelector('.summary-text')?.textContent,
313
+ related_works: Array.from(document.querySelectorAll('.formula-item')).map(item => {
314
+ const variablesElement = item.querySelector('.formula-variables');
315
+ const contextElement = item.querySelector('.formula-context');
316
+ const chineseElement = item.querySelector('.formula-chinese');
317
+
318
+ return {
319
+ formula: item.querySelector('.formula-expression').textContent,
320
+ type: item.querySelector('.formula-type').textContent.toLowerCase(),
321
+ description: item.querySelector('.formula-description').textContent,
322
+ variables: variablesElement ? variablesElement.textContent.replace('Variables: ', '') : '',
323
+ context: contextElement ? contextElement.textContent.replace('Context: ', '') : '',
324
+ chinese_description: chineseElement ? chineseElement.textContent.replace('中文描述: ', '') : ''
325
+ };
326
+ })
327
+ };
328
+
329
+ const blob = new Blob([JSON.stringify(results, null, 2)], { type: 'application/json' });
330
+ const url = URL.createObjectURL(blob);
331
+ const a = document.createElement('a');
332
+ a.href = url;
333
+ a.download = 'paper_analysis_results.json';
334
+ document.body.appendChild(a);
335
+ a.click();
336
+ document.body.removeChild(a);
337
+ URL.revokeObjectURL(url);
338
+ });
339
+
340
+ // Utility Functions
341
+ function showNotification(message, type) {
342
+ const notification = document.createElement('div');
343
+ notification.className = `notification ${type}`;
344
+ notification.textContent = message;
345
+ document.body.appendChild(notification);
346
+
347
+ setTimeout(() => {
348
+ notification.remove();
349
+ }, 3000);
350
+ }
351
+
352
+ let loadingElement = null;
353
+
354
+ function showLoading(message) {
355
+ loadingElement = document.createElement('div');
356
+ loadingElement.className = 'loading-overlay';
357
+ loadingElement.innerHTML = `
358
+ <div class="loading-spinner"></div>
359
+ <div class="loading-message">${message}</div>
360
+ `;
361
+ document.body.appendChild(loadingElement);
362
+ }
363
+
364
+ function hideLoading() {
365
+ if (loadingElement) {
366
+ loadingElement.remove();
367
+ loadingElement = null;
368
+ }
369
+ }
370
+
371
+ // Function to switch between English and Chinese variable descriptions
372
+ function switchVariableTab(button, language) {
373
+ const variablesContainer = button.closest('.formula-variables');
374
+ const tabs = variablesContainer.querySelectorAll('.var-tab-btn');
375
+ const contents = variablesContainer.querySelectorAll('.variables-list');
376
+
377
+ // Update tab buttons
378
+ tabs.forEach(tab => tab.classList.remove('active'));
379
+ button.classList.add('active');
380
+
381
+ // Update content visibility
382
+ contents.forEach(content => content.classList.remove('active'));
383
+ const targetContent = variablesContainer.querySelector(`.${language}-vars`);
384
+ if (targetContent) {
385
+ targetContent.classList.add('active');
386
+ }
387
+ }
388
+
389
+ // Make function global so it can be called from onclick
390
+ window.switchVariableTab = switchVariableTab;