Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	add choose lang
Browse files- db/__pycache__/mongodb.cpython-310.pyc +0 -0
- excel/__pycache__/excel_translate.cpython-310.pyc +0 -0
- excel/excel_translate.py +0 -1
- pages/upload.py +2 -1
- powerpoint/__pycache__/__init__.cpython-310.pyc +0 -0
- powerpoint/__pycache__/pptx_object.cpython-310.pyc +0 -0
- powerpoint/__pycache__/xml_handling.cpython-310.pyc +0 -0
- translate/__pycache__/translator.cpython-310.pyc +0 -0
- translate/translator.py +1 -2
- word/__pycache__/word_translate.cpython-310.pyc +0 -0
    	
        db/__pycache__/mongodb.cpython-310.pyc
    ADDED
    
    | Binary file (5.88 kB). View file | 
|  | 
    	
        excel/__pycache__/excel_translate.cpython-310.pyc
    ADDED
    
    | Binary file (4.03 kB). View file | 
|  | 
    	
        excel/excel_translate.py
    CHANGED
    
    | @@ -7,7 +7,6 @@ import io | |
| 7 | 
             
            import pandas as pd
         | 
| 8 | 
             
            import pymongo
         | 
| 9 | 
             
            import gridfs
         | 
| 10 | 
            -
            from io import BytesIO
         | 
| 11 | 
             
            import tempfile
         | 
| 12 | 
             
            import os
         | 
| 13 |  | 
|  | |
| 7 | 
             
            import pandas as pd
         | 
| 8 | 
             
            import pymongo
         | 
| 9 | 
             
            import gridfs
         | 
|  | |
| 10 | 
             
            import tempfile
         | 
| 11 | 
             
            import os
         | 
| 12 |  | 
    	
        pages/upload.py
    CHANGED
    
    | @@ -25,6 +25,7 @@ st.title("Upload PPTX to MongoDB") | |
| 25 | 
             
            # st.set_option("server.fileUploader.allowMediaFiles", True)
         | 
| 26 | 
             
            uploaded_file = st.file_uploader("Chọn file")
         | 
| 27 | 
             
            file_name_input = st.text_input("Tên file để lưu (không cần .pptx)", value="")
         | 
|  | |
| 28 |  | 
| 29 | 
             
            final_pptx_id = None  # Biến lưu ID file sau khi xử lý
         | 
| 30 |  | 
| @@ -39,7 +40,7 @@ if uploaded_file is not None: | |
| 39 |  | 
| 40 | 
             
                        xml_file_id = ppt_to_xml_mongodb(file_id)
         | 
| 41 | 
             
                        text_dict = extract_text_from_xml(file_id=xml_file_id)
         | 
| 42 | 
            -
                        translated_dict = translate_text_dict(text_dict,  | 
| 43 |  | 
| 44 | 
             
                        final_xml_id = update_xml_with_translated_text_mongodb(xml_file_id, translated_dict)
         | 
| 45 | 
             
                        st.write(f"Final XML ID: {final_xml_id}")
         | 
|  | |
| 25 | 
             
            # st.set_option("server.fileUploader.allowMediaFiles", True)
         | 
| 26 | 
             
            uploaded_file = st.file_uploader("Chọn file")
         | 
| 27 | 
             
            file_name_input = st.text_input("Tên file để lưu (không cần .pptx)", value="")
         | 
| 28 | 
            +
            target_lang = st.selectbox("Chọn ngôn ngữ dịch", ["english", "vietnamese"])
         | 
| 29 |  | 
| 30 | 
             
            final_pptx_id = None  # Biến lưu ID file sau khi xử lý
         | 
| 31 |  | 
|  | |
| 40 |  | 
| 41 | 
             
                        xml_file_id = ppt_to_xml_mongodb(file_id)
         | 
| 42 | 
             
                        text_dict = extract_text_from_xml(file_id=xml_file_id)
         | 
| 43 | 
            +
                        translated_dict = translate_text_dict(text_dict, target_lang=target_lang, gemini_api=api_key)
         | 
| 44 |  | 
| 45 | 
             
                        final_xml_id = update_xml_with_translated_text_mongodb(xml_file_id, translated_dict)
         | 
| 46 | 
             
                        st.write(f"Final XML ID: {final_xml_id}")
         | 
    	
        powerpoint/__pycache__/__init__.cpython-310.pyc
    ADDED
    
    | Binary file (157 Bytes). View file | 
|  | 
    	
        powerpoint/__pycache__/pptx_object.cpython-310.pyc
    ADDED
    
    | Binary file (8.97 kB). View file | 
|  | 
    	
        powerpoint/__pycache__/xml_handling.cpython-310.pyc
    ADDED
    
    | Binary file (9.66 kB). View file | 
|  | 
    	
        translate/__pycache__/translator.cpython-310.pyc
    ADDED
    
    | Binary file (2.92 kB). View file | 
|  | 
    	
        translate/translator.py
    CHANGED
    
    | @@ -6,8 +6,7 @@ import google.generativeai as genai | |
| 6 | 
             
            def translate_text_dict(text_dict: Dict[str, List[str]], source_lang: str, target_lang: str = "vi", gemini_api: str = "") -> Dict[str, List[str]]:
         | 
| 7 | 
             
                def translate_batch(batch_dict: Dict[str, List[str]]) -> Dict[str, List[str]]:
         | 
| 8 | 
             
                    """Translates a single batch of text."""
         | 
| 9 | 
            -
                    prompt = f"""The following python dictionary contains pieces of text that form a whole document: {json.dumps(batch_dict)}
         | 
| 10 | 
            -
                    The text is in {source_lang}, with a chance of there being phrases in other languages as well.
         | 
| 11 |  | 
| 12 | 
             
                    Read through the entire dictionary, then translate the texts into {target_lang} so that the meaning is as close to the intended context as possible.
         | 
| 13 |  | 
|  | |
| 6 | 
             
            def translate_text_dict(text_dict: Dict[str, List[str]], source_lang: str, target_lang: str = "vi", gemini_api: str = "") -> Dict[str, List[str]]:
         | 
| 7 | 
             
                def translate_batch(batch_dict: Dict[str, List[str]]) -> Dict[str, List[str]]:
         | 
| 8 | 
             
                    """Translates a single batch of text."""
         | 
| 9 | 
            +
                    prompt = f"""The following python dictionary contains pieces of text that form a whole document: {json.dumps(batch_dict)}.
         | 
|  | |
| 10 |  | 
| 11 | 
             
                    Read through the entire dictionary, then translate the texts into {target_lang} so that the meaning is as close to the intended context as possible.
         | 
| 12 |  | 
    	
        word/__pycache__/word_translate.cpython-310.pyc
    ADDED
    
    | Binary file (6.63 kB). View file | 
|  |