Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write to xml #34

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions mailcom/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from transformers import pipeline
from pathlib import Path
from mailcom.inout import InoutHandler
from dicttoxml import dicttoxml
from xml.dom.minidom import parseString

# please modify this section depending on your setup
# input language - either "es" or "fr"
Expand Down Expand Up @@ -118,17 +120,27 @@ def make_dir(path: str):
# process the text
io = InoutHandler(path_input)
io.list_of_files()
io = InoutHandler(path_input)
io.list_of_files()
# html_files = list_of_files(path_input, "html")
for file in io.email_list:
text = io.get_text(file)
text = io.get_html_text(text)
print(text)
print(io.email_content["date"])
print(io.email_content["attachment"])
print(io.email_content["attachement type"])
# print(text)
# print(io.email_content["date"])
# print(io.email_content["attachment"])
# print(io.email_content["attachement type"])
# skip this text if email could not be parsed
if not text:
continue
xml = dicttoxml(io.email_content["content"])
# xml = dicttoxml(io.email_content) Different options for review
xml_decode = xml.decode()
xmlfile = open(path_output / "dict.xml", "w")
xmlfile.write(xml_decode)
xmlfile.close()
print(parseString(xml).toprettyxml())

# doc_spacy = nlp_spacy(text)
# text = get_sentences(doc_spacy)
# start with first line
Expand Down
Loading