Upload 9 files
Browse files- .gitattributes +1 -0
- Jy.py +14 -0
- LPHD.db +3 -0
- README.md +93 -0
- formatear_achivos-transfo.py +19 -0
- selectGreekpapyri.py +26 -0
- trainingtexts2df copy.py +46 -0
- trainingtexts2df.py +46 -0
- transfo copy.py +30 -0
- transfo.py +43 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
LPHD.db filter=lfs diff=lfs merge=lfs -text
|
Jy.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Load the saved model
|
2 |
+
with open("model.pkl", "rb") as f:
|
3 |
+
loaded_learn = pickle.load(f)
|
4 |
+
|
5 |
+
# Define input text
|
6 |
+
TEXT = "I liked this movie because"
|
7 |
+
N_WORDS = 40
|
8 |
+
N_SENTENCES = 2
|
9 |
+
|
10 |
+
# Generate predictions
|
11 |
+
preds = [loaded_learn.predict(TEXT, N_WORDS, temperature=0.75) for _ in range(N_SENTENCES)]
|
12 |
+
|
13 |
+
# Print predictions
|
14 |
+
print("\n".join(preds))
|
LPHD.db
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66f5934465da1c249642a918c25f86f7264d6900ce054c46a7952f04e313741f
|
3 |
+
size 129122304
|
README.md
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Papyri.info bot
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
## Getting started
|
6 |
+
|
7 |
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
8 |
+
|
9 |
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
10 |
+
|
11 |
+
## Add your files
|
12 |
+
|
13 |
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
14 |
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
15 |
+
|
16 |
+
```
|
17 |
+
cd existing_repo
|
18 |
+
git remote add origin https://git.csic.es/labhd-ilc-internal/papyri.info-bot.git
|
19 |
+
git branch -M main
|
20 |
+
git push -uf origin main
|
21 |
+
```
|
22 |
+
|
23 |
+
## Integrate with your tools
|
24 |
+
|
25 |
+
- [ ] [Set up project integrations](https://git.csic.es/labhd-ilc-internal/papyri.info-bot/-/settings/integrations)
|
26 |
+
|
27 |
+
## Collaborate with your team
|
28 |
+
|
29 |
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
30 |
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
31 |
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
32 |
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
33 |
+
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
34 |
+
|
35 |
+
## Test and Deploy
|
36 |
+
|
37 |
+
Use the built-in continuous integration in GitLab.
|
38 |
+
|
39 |
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
|
40 |
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
41 |
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
42 |
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
43 |
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
44 |
+
|
45 |
+
***
|
46 |
+
|
47 |
+
# Editing this README
|
48 |
+
|
49 |
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
50 |
+
|
51 |
+
## Suggestions for a good README
|
52 |
+
|
53 |
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
54 |
+
|
55 |
+
## Name
|
56 |
+
Choose a self-explaining name for your project.
|
57 |
+
|
58 |
+
## Description
|
59 |
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
60 |
+
|
61 |
+
## Badges
|
62 |
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
63 |
+
|
64 |
+
## Visuals
|
65 |
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
66 |
+
|
67 |
+
## Installation
|
68 |
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
69 |
+
|
70 |
+
## Usage
|
71 |
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
72 |
+
|
73 |
+
## Support
|
74 |
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
75 |
+
|
76 |
+
## Roadmap
|
77 |
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
78 |
+
|
79 |
+
## Contributing
|
80 |
+
State if you are open to contributions and what your requirements are for accepting them.
|
81 |
+
|
82 |
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
83 |
+
|
84 |
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
85 |
+
|
86 |
+
## Authors and acknowledgment
|
87 |
+
Show your appreciation to those who have contributed to the project.
|
88 |
+
|
89 |
+
## License
|
90 |
+
For open source projects, say how it is licensed.
|
91 |
+
|
92 |
+
## Project status
|
93 |
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
formatear_achivos-transfo.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
|
4 |
+
|
5 |
+
corpus = 'training_texts/DDB_EpiDoc_XML/'
|
6 |
+
|
7 |
+
path_list = []
|
8 |
+
for root, dirs, files in os.walk(corpus):
|
9 |
+
if len(files)>0:
|
10 |
+
#print(root)
|
11 |
+
path_list.append(root)
|
12 |
+
|
13 |
+
for p in path_list:
|
14 |
+
froot = p +'/'
|
15 |
+
for f in os.listdir(p):
|
16 |
+
fin = froot+f
|
17 |
+
fout = re.sub('xml$', 'txt', fin)
|
18 |
+
print(fout)
|
19 |
+
os.rename(fin, fout)
|
selectGreekpapyri.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sqlite3
|
2 |
+
import re
|
3 |
+
import os
|
4 |
+
import shutil
|
5 |
+
|
6 |
+
con = sqlite3.connect('LPHD.db')
|
7 |
+
cur = con.cursor()
|
8 |
+
|
9 |
+
sql_fisgreek = '''SELECT DDB_isGREEK.ID_DDB, DDB_fpath.fpath
|
10 |
+
FROM DDB_isGREEK
|
11 |
+
INNER JOIN DDB_fpath
|
12 |
+
ON DDB_isGREEK.ID_DDB=DDB_fpath.ID_DDB
|
13 |
+
WHERE IsGreek="yes";'''
|
14 |
+
|
15 |
+
res_fisgreek = cur.execute(sql_fisgreek)
|
16 |
+
fisgreek = res_fisgreek.fetchall()
|
17 |
+
|
18 |
+
if not os.path.isdir('training_texts2'):
|
19 |
+
os.makedirs('training_texts2')
|
20 |
+
for idpap, path in fisgreek:
|
21 |
+
corpusf = re.sub('^idp\.data', 'training_texts', path)
|
22 |
+
corpusf = re.sub('xml$', 'txt', corpusf)
|
23 |
+
nfname = 'training_texts2/'+ re.search('[^/]+\.txt', corpusf).group(0)
|
24 |
+
if os.path.exists(corpusf):
|
25 |
+
shutil.copyfile(corpusf, nfname)
|
26 |
+
|
trainingtexts2df copy.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pandas as pd
|
3 |
+
#from cltk.languages.pipelines import GreekPipeline
|
4 |
+
#from cltk import NLP
|
5 |
+
import regex
|
6 |
+
|
7 |
+
#model_gk = GreekPipeline()
|
8 |
+
#print(model_gk.processes)
|
9 |
+
|
10 |
+
"""nlp_gk = NLP(language='grc')
|
11 |
+
nlp_gk.pipeline.processes.pop(-1)
|
12 |
+
nlp_gk.pipeline.processes.pop(-1)"""
|
13 |
+
#print(nlp_gk.pipeline.processes)
|
14 |
+
def tok(text):
|
15 |
+
txt_files = 'training_texts2/'
|
16 |
+
dict = {'text': [], 'text_':[]}
|
17 |
+
for f in os.listdir(txt_files):
|
18 |
+
fpath = txt_files+f
|
19 |
+
raw = open(fpath).read()
|
20 |
+
noblank = regex.sub('^\s+', '', raw)
|
21 |
+
noblank = regex.sub('\s+$', '', noblank)
|
22 |
+
if len(noblank)>0:
|
23 |
+
toks = regex.split('\s', noblank)
|
24 |
+
ntoks = []
|
25 |
+
for tok in toks:
|
26 |
+
if regex.search('.+[·.,]$',tok):
|
27 |
+
#print(regex.search('.+[·.,]$',tok).group(0))
|
28 |
+
groups_re = '(?P<tok1>.+)(?P<tok2>[·.,])$'
|
29 |
+
groups = regex.match(groups_re, tok)
|
30 |
+
tok1 = groups.group('tok1')
|
31 |
+
tok2 = groups.group('tok2')
|
32 |
+
if regex.fullmatch('[.]+', tok1):
|
33 |
+
ntoks.append(tok)
|
34 |
+
#print(tok)
|
35 |
+
else:
|
36 |
+
ntoks+=[tok1, tok2]
|
37 |
+
#print(groups.groupdict())
|
38 |
+
elif len(tok)==0:
|
39 |
+
continue
|
40 |
+
else:
|
41 |
+
ntoks.append(tok)
|
42 |
+
print(ntoks, '\n\n\n')
|
43 |
+
#print(toks)
|
44 |
+
#cltk_doc = nlp_gk.analyze(text=noblank)
|
45 |
+
#print(f'\nINPUT:\n{noblank}\n\nOUTPUT:\n{ntoks}\n')
|
46 |
+
|
trainingtexts2df.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pandas as pd
|
3 |
+
#from cltk.languages.pipelines import GreekPipeline
|
4 |
+
#from cltk import NLP
|
5 |
+
import regex
|
6 |
+
|
7 |
+
#model_gk = GreekPipeline()
|
8 |
+
#print(model_gk.processes)
|
9 |
+
|
10 |
+
"""nlp_gk = NLP(language='grc')
|
11 |
+
nlp_gk.pipeline.processes.pop(-1)
|
12 |
+
nlp_gk.pipeline.processes.pop(-1)"""
|
13 |
+
#print(nlp_gk.pipeline.processes)
|
14 |
+
def tok(text):
|
15 |
+
txt_files = 'training_texts2/'
|
16 |
+
dict = {'text': [], 'text_':[]}
|
17 |
+
for f in os.listdir(txt_files):
|
18 |
+
fpath = txt_files+f
|
19 |
+
raw = open(fpath).read()
|
20 |
+
noblank = regex.sub('^\s+', '', raw)
|
21 |
+
noblank = regex.sub('\s+$', '', noblank)
|
22 |
+
if len(noblank)>0:
|
23 |
+
toks = regex.split('\s', noblank)
|
24 |
+
ntoks = []
|
25 |
+
for tok in toks:
|
26 |
+
if regex.search('.+[·.,]$',tok):
|
27 |
+
#print(regex.search('.+[·.,]$',tok).group(0))
|
28 |
+
groups_re = '(?P<tok1>.+)(?P<tok2>[·.,])$'
|
29 |
+
groups = regex.match(groups_re, tok)
|
30 |
+
tok1 = groups.group('tok1')
|
31 |
+
tok2 = groups.group('tok2')
|
32 |
+
if regex.fullmatch('[.]+', tok1):
|
33 |
+
ntoks.append(tok)
|
34 |
+
#print(tok)
|
35 |
+
else:
|
36 |
+
ntoks+=[tok1, tok2]
|
37 |
+
#print(groups.groupdict())
|
38 |
+
elif len(tok)==0:
|
39 |
+
continue
|
40 |
+
else:
|
41 |
+
ntoks.append(tok)
|
42 |
+
print(ntoks, '\n\n\n')
|
43 |
+
#print(toks)
|
44 |
+
#cltk_doc = nlp_gk.analyze(text=noblank)
|
45 |
+
#print(f'\nINPUT:\n{noblank}\n\nOUTPUT:\n{ntoks}\n')
|
46 |
+
|
transfo copy.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import subprocess
|
3 |
+
import re
|
4 |
+
|
5 |
+
saxon_jar = "./SaxonHE12-5J/saxon-he-12.5.jar" # Remplacez par le chemin vers le fichier saxon9he.jar
|
6 |
+
xsl_file = "./Stylesheets-master/start-txt.xsl" # Remplacez par votre fichier XSL
|
7 |
+
corpus = 'corpus/DDB_EpiDoc_XML/'
|
8 |
+
path_list = []
|
9 |
+
|
10 |
+
for root, dirs, files in os.walk(corpus):
|
11 |
+
if len(files)>0:
|
12 |
+
path_list.append(root)
|
13 |
+
if not os.path.isdir('training_texts/'):
|
14 |
+
os.makedirs('training_texts/')
|
15 |
+
for root in path_list:
|
16 |
+
inputdir = root
|
17 |
+
outdir = re.sub('^corpus/', 'training_texts/', root)
|
18 |
+
if not os.path.isdir(outdir):
|
19 |
+
os.makedirs(outdir)
|
20 |
+
#print(root)
|
21 |
+
command = [
|
22 |
+
"java", "-jar", saxon_jar,
|
23 |
+
"-s:" + root,
|
24 |
+
"-xsl:" + xsl_file,
|
25 |
+
"-o:" + outdir
|
26 |
+
]
|
27 |
+
|
28 |
+
# Exécuter la commande
|
29 |
+
subprocess.run(command, check=True)
|
30 |
+
|
transfo.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
|
5 |
+
# Chemins d'entrée et sortie
|
6 |
+
input_directory = "./corpus" # Remplacez par le chemin du dossier contenant les fichiers XML
|
7 |
+
xsl_file = "./Stylesheets-master/start-txt.xsl" # Remplacez par votre fichier XSL
|
8 |
+
output_directory = "./txt" # Remplacez par le dossier où stocker les fichiers TXT
|
9 |
+
saxon_jar = "./SaxonHE12-5J/saxon-he-12.5.jar" # Remplacez par le chemin vers le fichier saxon9he.jar
|
10 |
+
|
11 |
+
# Fonction pour appliquer la transformation et maintenir la structure des sous-dossiers
|
12 |
+
def transform_xml_files(input_dir, output_dir):
|
13 |
+
for root, dirs, files in os.walk(input_dir): # Parcours du répertoire source
|
14 |
+
for file in files:
|
15 |
+
if file.endswith(".xml"): # Seulement les fichiers XML
|
16 |
+
xml_file_path = os.path.join(root, file)
|
17 |
+
|
18 |
+
# Crée un chemin de sortie correspondant à la structure du répertoire source
|
19 |
+
relative_path = os.path.relpath(root, input_dir) # Chemin relatif
|
20 |
+
output_subdir = os.path.join(output_dir, relative_path) # Crée le sous-dossier dans le répertoire de sortie
|
21 |
+
os.makedirs(output_subdir, exist_ok=True) # Crée les sous-dossiers si nécessaire
|
22 |
+
|
23 |
+
# Chemin de sortie pour le fichier transformé
|
24 |
+
output_file_path = os.path.join(output_subdir, file.replace(".xml", ".txt"))
|
25 |
+
|
26 |
+
try:
|
27 |
+
# Commande Java pour exécuter Saxon
|
28 |
+
command = [
|
29 |
+
"java", "-jar", saxon_jar,
|
30 |
+
"-s:" + xml_file_path,
|
31 |
+
"-xsl:" + xsl_file,
|
32 |
+
"-o:" + output_file_path
|
33 |
+
]
|
34 |
+
|
35 |
+
# Exécuter la commande
|
36 |
+
subprocess.run(command, check=True)
|
37 |
+
print(f"Transformation appliquée à {xml_file_path} -> {output_file_path}")
|
38 |
+
|
39 |
+
except subprocess.CalledProcessError as e:
|
40 |
+
print(f"Erreur lors de la transformation du fichier {xml_file_path}: {e}")
|
41 |
+
|
42 |
+
# Exécuter la transformation
|
43 |
+
transform_xml_files(input_directory, output_directory)
|