PgsFile 0.4.8__py3-none-any.whl → 0.5.0__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.
- PgsFile/PgsFile.py +74 -0
- PgsFile/__init__.py +1 -0
- PgsFile/models/prompts/8. TitleCase prompt.txt +25 -0
- {PgsFile-0.4.8.dist-info → PgsFile-0.5.0.dist-info}/METADATA +2 -2
- {PgsFile-0.4.8.dist-info → PgsFile-0.5.0.dist-info}/RECORD +8 -7
- {PgsFile-0.4.8.dist-info → PgsFile-0.5.0.dist-info}/LICENSE +0 -0
- {PgsFile-0.4.8.dist-info → PgsFile-0.5.0.dist-info}/WHEEL +0 -0
- {PgsFile-0.4.8.dist-info → PgsFile-0.5.0.dist-info}/top_level.txt +0 -0
PgsFile/PgsFile.py
CHANGED
|
@@ -4142,3 +4142,77 @@ def tfidf_keyword_extraction(documents, top_percent=(0.0, 0.10)):
|
|
|
4142
4142
|
|
|
4143
4143
|
return full_list, candidates
|
|
4144
4144
|
|
|
4145
|
+
|
|
4146
|
+
from xml.dom.minidom import Document
|
|
4147
|
+
def maketmx(tmx_path, source_list, target_list, source_lang="zh-CN", target_lang="en-US"):
|
|
4148
|
+
"""
|
|
4149
|
+
Generate a TMX (Translation Memory eXchange) file for any two language pairs.
|
|
4150
|
+
|
|
4151
|
+
Parameters
|
|
4152
|
+
----------
|
|
4153
|
+
tmx_path : str
|
|
4154
|
+
Path to save the TMX file, e.g., "translation_memory.tmx".
|
|
4155
|
+
source_list : list of str
|
|
4156
|
+
List of source language segments, e.g., ["你好", "再见"].
|
|
4157
|
+
target_list : list of str
|
|
4158
|
+
List of target language segments, e.g., ["Hello", "Goodbye"].
|
|
4159
|
+
**Must have the same number of elements as `source_list`.**
|
|
4160
|
+
source_lang : str, optional
|
|
4161
|
+
Source language code, e.g., "zh-CN" (default), "fr-FR", "de-DE".
|
|
4162
|
+
target_lang : str, optional
|
|
4163
|
+
Target language code, e.g., "en-US" (default), "es-ES", "ja-JP".
|
|
4164
|
+
|
|
4165
|
+
Returns
|
|
4166
|
+
-------
|
|
4167
|
+
None
|
|
4168
|
+
Writes the TMX file to the specified path.
|
|
4169
|
+
|
|
4170
|
+
Example
|
|
4171
|
+
-------
|
|
4172
|
+
# Chinese to English
|
|
4173
|
+
maketmx("zh_en.tmx", ["你好", "再见"], ["Hello", "Goodbye"], "zh-CN", "en-US")
|
|
4174
|
+
|
|
4175
|
+
# French to German
|
|
4176
|
+
maketmx("fr_de.tmx", ["Bonjour", "Au revoir"], ["Hallo", "Auf Wiedersehen"], "fr-FR", "de-DE")
|
|
4177
|
+
"""
|
|
4178
|
+
doc = Document()
|
|
4179
|
+
tmx = doc.createElement("tmx")
|
|
4180
|
+
tmx.setAttribute("version", "1.0")
|
|
4181
|
+
doc.appendChild(tmx)
|
|
4182
|
+
|
|
4183
|
+
header = doc.createElement("header")
|
|
4184
|
+
header.setAttribute("creationtool", "PgsFile")
|
|
4185
|
+
header.setAttribute("creationtoolversion", "1.1.0")
|
|
4186
|
+
header.setAttribute("creationtooldeveloper", "Dr. Guisheng PAN, panguisheng@sufe.edu.cn")
|
|
4187
|
+
header.setAttribute("srclang", source_lang)
|
|
4188
|
+
header.setAttribute("trtlang", target_lang)
|
|
4189
|
+
header.setAttribute("datatype", "plaintext")
|
|
4190
|
+
tmx.appendChild(header)
|
|
4191
|
+
|
|
4192
|
+
body = doc.createElement("body")
|
|
4193
|
+
tmx.appendChild(body)
|
|
4194
|
+
|
|
4195
|
+
for i in range(len(source_list)):
|
|
4196
|
+
tu = doc.createElement("tu")
|
|
4197
|
+
body.appendChild(tu)
|
|
4198
|
+
|
|
4199
|
+
# Source language segment
|
|
4200
|
+
tuv = doc.createElement("tuv")
|
|
4201
|
+
tuv.setAttribute("xml:lang", source_lang)
|
|
4202
|
+
tu.appendChild(tuv)
|
|
4203
|
+
seg = doc.createElement("seg")
|
|
4204
|
+
seg_text = doc.createTextNode(source_list[i])
|
|
4205
|
+
seg.appendChild(seg_text)
|
|
4206
|
+
tuv.appendChild(seg)
|
|
4207
|
+
|
|
4208
|
+
# Target language segment
|
|
4209
|
+
tuv = doc.createElement("tuv")
|
|
4210
|
+
tuv.setAttribute("xml:lang", target_lang)
|
|
4211
|
+
tu.appendChild(tuv)
|
|
4212
|
+
seg = doc.createElement("seg")
|
|
4213
|
+
seg_text = doc.createTextNode(target_list[i])
|
|
4214
|
+
seg.appendChild(seg_text)
|
|
4215
|
+
tuv.appendChild(seg)
|
|
4216
|
+
|
|
4217
|
+
with open(tmx_path, 'w', encoding='utf-8') as f:
|
|
4218
|
+
doc.writexml(f, indent='\t', newl='\n', addindent='\t')
|
PgsFile/__init__.py
CHANGED
|
@@ -19,6 +19,7 @@ from .PgsFile import mhtml2html
|
|
|
19
19
|
# 4. Text data storage
|
|
20
20
|
from .PgsFile import write_to_txt, write_to_excel, write_to_json, write_to_json_lines, append_dict_to_json, save_dict_to_excel, file_to_list_of_dicts
|
|
21
21
|
from .PgsFile import write_to_excel_normal
|
|
22
|
+
from .PgsFile import maketmx
|
|
22
23
|
|
|
23
24
|
# 5. File/folder process
|
|
24
25
|
from .PgsFile import FilePath, FileName, DirList
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Prompt for APA Title Case Conversion
|
|
2
|
+
Task:
|
|
3
|
+
Convert the provided article or book title into APA title case (7th edition). Follow APA capitalization rules carefully.
|
|
4
|
+
|
|
5
|
+
Rules:
|
|
6
|
+
1. Always capitalize:
|
|
7
|
+
o The first word of the title and subtitle (even if it’s a minor word).
|
|
8
|
+
o The first word after a colon (:) or em dash (—).
|
|
9
|
+
o All major words: nouns, verbs (including linking verbs), adjectives, adverbs, pronouns, and subordinating conjunctions.
|
|
10
|
+
o All words with four or more letters (e.g., “With,” “From”).
|
|
11
|
+
o The second element of a hyphenated major word (e.g., “Self-Report,” not “Self-report”).
|
|
12
|
+
o Proper nouns (e.g., “Freud,” “United States”).
|
|
13
|
+
2. Lowercase:
|
|
14
|
+
o Articles: a, an, the.
|
|
15
|
+
o Short coordinating conjunctions (three letters or fewer): and, but, or.
|
|
16
|
+
o Short prepositions (three letters or fewer): in, of, on, to.
|
|
17
|
+
o Exception: Capitalize if they are the first word of the title/subtitle or immediately follow a colon or em dash.
|
|
18
|
+
|
|
19
|
+
Output format:
|
|
20
|
+
Return the result as a Python string, with no extra explanation:
|
|
21
|
+
"My Revised Title"
|
|
22
|
+
|
|
23
|
+
Now convert this title:
|
|
24
|
+
Target title: {your_title}
|
|
25
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PgsFile
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: This module simplifies Python package management, script execution, file handling, web scraping, and multimedia downloads. The module supports (LLM-based) NLP tasks such as OCR, tokenization, lemmatization, POS tagging, NER, ATE, dependency parsing, MDD, WSD, LIWC, MIP analysis and Chinese-English sentence alignment. It also generates word lists, and plots data, aiding literary students. Ideal for scraping data, cleaning text, and analyzing language, it offers user-friendly tools to streamline workflows.
|
|
5
5
|
Home-page: https://mp.weixin.qq.com/s/lWMkYDWQMjBJNKY2vMYTpw
|
|
6
6
|
Author: Pan Guisheng
|
|
@@ -31,7 +31,7 @@ Key Features:
|
|
|
31
31
|
1. **Web Scraping:** Easily scrape data from websites and download multimedia content.
|
|
32
32
|
2. **Package Management:** Install, uninstall, and manage Python packages with simple commands.
|
|
33
33
|
3. **Data Retrieval:** Extract data from various file formats like text, JSON, TSV, Excel, XML, and HTML (both online and offline).
|
|
34
|
-
4. **Data Storage:** Write and append data to text files, Excel, JSON, and JSON lines.
|
|
34
|
+
4. **Data Storage:** Write and append data to text files, Excel, JSON, TMX, and JSON lines.
|
|
35
35
|
5. **File and Folder Processing:** Manage file paths, create directories, move or copy files, and search for files with specific keywords.
|
|
36
36
|
6. **Data Cleaning:** Clean text, handle punctuation, remove stopwords, convert Markdown strings into Python objects, and prepare data for analysis, utilizing valuable corpora and dictionaries such as CET-4/6 vocabulary, BE21 and BNC-COCA word lists.
|
|
37
37
|
7. **NLP:** Perform OCR, word tokenization, lemmatization, POS tagging, NER, dependency parsing, ATE, MDD, WSD, LIWC, MIP analysis, and Chinese-English sentence alignment using prepared LLM prompts.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
PgsFile/PgsFile.py,sha256=
|
|
2
|
-
PgsFile/__init__.py,sha256=
|
|
1
|
+
PgsFile/PgsFile.py,sha256=szt4jGqE_q2FYN399mZzdtsWUNK678Sy7y41xEvdL3M,172583
|
|
2
|
+
PgsFile/__init__.py,sha256=YkDTLWtveSeN4I5ZXSmdp7YZFOHb4yEzxQB82DEHk9s,3704
|
|
3
3
|
PgsFile/Corpora/Idioms/English_Idioms_8774.txt,sha256=qlsP0yI_XGECBRiPZuLkGZpdasc77sWSKexANu7v8_M,175905
|
|
4
4
|
PgsFile/Corpora/Monolingual/Chinese/People's Daily 20130605/Raw/00000000.txt,sha256=SLGGSMSb7Ff1RoBstsTW3yX2wNZpqEUchFNpcI-mrR4,1513
|
|
5
5
|
PgsFile/Corpora/Monolingual/Chinese/People's Daily 20130605/Raw/00000001.txt,sha256=imOa6UoCOIZoPXT4_HNHgCUJtd4FTIdk2FZNHNBgJyg,3372
|
|
@@ -2592,8 +2592,9 @@ PgsFile/models/prompts/4. OCR prompt.txt,sha256=YxUQ2IlE52k0fcBnGsuOHqWAmfiEmIu6
|
|
|
2592
2592
|
PgsFile/models/prompts/5. ATE prompt.txt,sha256=5wu0gGlsV7DI0LruYM3-uAC6brppyYD0IoiFVjMqm5Y,1553
|
|
2593
2593
|
PgsFile/models/prompts/6. ATE3 prompt.txt,sha256=VnaXpPa6BgZHUcm8PxmP_qgU-8xEoTB3XcBqjwCUy_g,1254
|
|
2594
2594
|
PgsFile/models/prompts/7. SentAlign prompt.txt,sha256=hXpqqC-CAgo8EytkJ0MaLhevLefALazWriY-ew39jxs,1537
|
|
2595
|
-
PgsFile
|
|
2596
|
-
PgsFile-0.
|
|
2597
|
-
PgsFile-0.
|
|
2598
|
-
PgsFile-0.
|
|
2599
|
-
PgsFile-0.
|
|
2595
|
+
PgsFile/models/prompts/8. TitleCase prompt.txt,sha256=4p-LfGy0xAj2uPi9amyMm41T6Z17VNpFFsGZOgWhROs,1136
|
|
2596
|
+
PgsFile-0.5.0.dist-info/LICENSE,sha256=cE5c-QToSkG1KTUsU8drQXz1vG0EbJWuU4ybHTRb5SE,1138
|
|
2597
|
+
PgsFile-0.5.0.dist-info/METADATA,sha256=PFoIaOZCwuxKpZtCcvblbO2Xs-i6DQnUvn9s9uIuW_A,3070
|
|
2598
|
+
PgsFile-0.5.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
2599
|
+
PgsFile-0.5.0.dist-info/top_level.txt,sha256=028hCfwhF3UpfD6X0rwtWpXI1RKSTeZ1ALwagWaSmX8,8
|
|
2600
|
+
PgsFile-0.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|