kopia lustrzana https://github.com/learn-awesome/learndb
				
				
				
			changed back to previous version
							rodzic
							
								
									4a5bb87b0e
								
							
						
					
					
						commit
						d8d5b0db71
					
				|  | @ -1,5 +1,5 @@ | |||
| const fetch = require('node-fetch'); // Import for webscraping in fetchContentFromURL()
 | ||||
| const { Configuration, OpenAIApi } = require('openai'); | ||||
| import { OpenAIApi, Configuration } from 'openai'; | ||||
| 
 | ||||
| // Function to fetch content from URL using a web scraping service
 | ||||
| async function fetchContentFromURL(url) { | ||||
|  | @ -16,11 +16,24 @@ async function fetchContentFromURL(url) { | |||
| } | ||||
| 
 | ||||
| function simplifyContent(content) { | ||||
|     let simplifiedContent = content.replace(/<[^>]*>/g, ''); // Remove HTML tags
 | ||||
|     simplifiedContent = simplifiedContent.replace(/<style[^>]*>.*<\/style>/gms, ''); // Remove CSS | ||||
|     simplifiedContent = simplifiedContent.replace(/<script[^>]*>.*<\/script>/gms, ''); // Remove JS | ||||
|     simplifiedContent = simplifiedContent.replace(/[^\w\s]/gi, ''); // Remove special characters
 | ||||
|     simplifiedContent = simplifiedContent.replace(/\s+/g, ' ').trim(); // Normalize whitespace
 | ||||
|     // Remove HTML tags
 | ||||
|     // let simplifiedContent = content.replace(/<[^>]*>/g, '');
 | ||||
|     // // Remove CSS within style tags
 | ||||
|     // simplifiedContent = simplifiedContent.replace(/<style[^>]*>.*<\/style>/gms, '');
 | ||||
|     // // Remove inline CSS and JavaScript within script tags
 | ||||
|     // simplifiedContent = simplifiedContent.replace(/<script[^>]*>.*<\/script>/gms, '');
 | ||||
|     // // Remove special characters and HTML entities
 | ||||
|     // simplifiedContent = simplifiedContent.replace(/[^\w\s]/gi, '').replace(/&[a-z]+;/gi, '');
 | ||||
|     // // Remove URLs
 | ||||
|     // simplifiedContent = simplifiedContent.replace(/https?:\/\/[^\s]+/gi, '');
 | ||||
|     // // Normalize whitespace
 | ||||
|     // simplifiedContent = simplifiedContent.replace(/\s+/g, ' ').trim();
 | ||||
|     // // Basic language simplification
 | ||||
|     // simplifiedContent = simplifiedContent.toLowerCase();
 | ||||
|     // // Simple summarization: taking the first few sentences
 | ||||
|     // const sentences = simplifiedContent.split('. ');
 | ||||
|     // const summarizedContent = sentences.slice(0, Math.min(5, sentences.length)).join('. ');
 | ||||
|     simplifiedContent = "hello maria"; | ||||
|     return simplifiedContent; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Huda Joad
						Huda Joad