Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pyDigest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ribary, Marton Dr (School of Law)
pyDigest
Commits
0dcabd82
Commit
0dcabd82
authored
4 years ago
by
Ribary, Marton Dr (School of Law)
Browse files
Options
Downloads
Patches
Plain Diff
Requirements for python venv
parent
03649db0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
demo/demo_001_lemmas.ipynb
+38
-37
38 additions, 37 deletions
demo/demo_001_lemmas.ipynb
requirements.txt
+11
-0
11 additions, 0 deletions
requirements.txt
with
51 additions
and
38 deletions
.gitignore
+
2
−
1
View file @
0dcabd82
...
@@ -2,4 +2,5 @@
...
@@ -2,4 +2,5 @@
_Work_in_progress/
_Work_in_progress/
_Scholarship/
_Scholarship/
_Notes/
_Notes/
_Drafts/
_Drafts/
\ No newline at end of file
.venv
\ No newline at end of file
This diff is collapsed.
Click to expand it.
demo/demo_001_lemma
text
.ipynb
→
demo/demo_001_lemma
s
.ipynb
+
38
−
37
View file @
0dcabd82
{
{
"cells": [
"metadata": {
{
"language_info": {
"cell_type": "markdown",
"codemirror_mode": {
"metadata": {},
"name": "ipython",
"source": [
"version": 3
"##1 Getting text ready for vectorization"
},
]
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5-final"
},
},
"orig_nbformat": 2,
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1,
"execution_count": 1,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"# Import packages and models from cltk and initialize tools\n",
"
# Import packages and models from cltk and initialize tools\n",
"from cltk.corpus.utils.importer import CorpusImporter\n",
"from cltk.corpus.utils.importer import CorpusImporter\n",
"from cltk.lemmatize.latin.backoff import BackoffLatinLemmatizer\n",
"from cltk.lemmatize.latin.backoff import BackoffLatinLemmatizer\n",
"corpus_importer = CorpusImporter('latin')\n",
"corpus_importer = CorpusImporter('latin')\n",
...
@@ -36,8 +51,8 @@
...
@@ -36,8 +51,8 @@
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"name": "stdout",
"text": [
"text": [
"hoc igitur ius nostrum constat aut ex scripto aut sine scripto ut apud graecos\n"
"hoc igitur ius nostrum constat aut ex scripto aut sine scripto ut apud graecos\n"
]
]
...
@@ -60,8 +75,8 @@
...
@@ -60,8 +75,8 @@
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"name": "stdout",
"text": [
"text": [
"['hoc', 'igitur', 'ius', 'nostrum', 'constat', 'aut', 'ex', 'scripto', 'aut', 'sine', 'scripto', 'ut', 'apud', 'graecos']\n"
"['hoc', 'igitur', 'ius', 'nostrum', 'constat', 'aut', 'ex', 'scripto', 'aut', 'sine', 'scripto', 'ut', 'apud', 'graecos']\n"
]
]
...
@@ -78,8 +93,8 @@
...
@@ -78,8 +93,8 @@
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"name": "stdout",
"text": [
"text": [
"[('hoc', 'hic'), ('igitur', 'igitur'), ('ius', 'ius'), ('nostrum', 'nos'), ('constat', 'consto'), ('aut', 'aut'), ('ex', 'ex'), ('scripto', 'scribo'), ('aut', 'aut'), ('sine', 'sine'), ('scripto', 'scribo'), ('ut', 'ut'), ('apud', 'apud'), ('graecos', 'graecus')]\n"
"[('hoc', 'hic'), ('igitur', 'igitur'), ('ius', 'ius'), ('nostrum', 'nos'), ('constat', 'consto'), ('aut', 'aut'), ('ex', 'ex'), ('scripto', 'scribo'), ('aut', 'aut'), ('sine', 'sine'), ('scripto', 'scribo'), ('ut', 'ut'), ('apud', 'apud'), ('graecos', 'graecus')]\n"
]
]
...
@@ -92,23 +107,23 @@
...
@@ -92,23 +107,23 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
9
,
"execution_count":
7
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"import pandas as pd\n",
"import pandas as pd\n",
"path_stoplist = '/home/mribary/
Dropbox
/py
D
igest/dump/D_stoplist_001.txt'\n",
"path_stoplist = '/home/mribary/
OneDrive/Git
/py
d
igest/dump/D_stoplist_001.txt'\n",
"stopwords = list(pd.read_csv(path_stoplist, header=None)[0]) # 57 custom stopwords"
"stopwords = list(pd.read_csv(path_stoplist, header=None)[0]) # 57 custom stopwords"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
11
,
"execution_count":
8
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"name": "stdout",
"text": [
"text": [
"igitur ius nos consto scribo scribo apud graecus\n"
"igitur ius nos consto scribo scribo apud graecus\n"
]
]
...
@@ -125,27 +140,13 @@
...
@@ -125,27 +140,13 @@
"textunit = textunit.strip()\n",
"textunit = textunit.strip()\n",
"print(textunit)"
"print(textunit)"
]
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
},
"language_info": {
{
"codemirror_mode": {
"cell_type": "code",
"name": "ipython",
"execution_count": null,
"version": 3
"metadata": {},
},
"outputs": [],
"file_extension": ".py",
"source": []
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
}
}
},
]
"nbformat": 4,
}
"nbformat_minor": 2
\ No newline at end of file
}
%% Cell type:markdown id: tags:
##1 Getting text ready for vectorization
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# Import packages and models from cltk and initialize tools
# Import packages and models from cltk and initialize tools
from
cltk.corpus.utils.importer
import
CorpusImporter
from
cltk.corpus.utils.importer
import
CorpusImporter
from
cltk.lemmatize.latin.backoff
import
BackoffLatinLemmatizer
from
cltk.lemmatize.latin.backoff
import
BackoffLatinLemmatizer
corpus_importer
=
CorpusImporter
(
'
latin
'
)
corpus_importer
=
CorpusImporter
(
'
latin
'
)
corpus_importer
.
import_corpus
(
'
latin_models_cltk
'
)
corpus_importer
.
import_corpus
(
'
latin_models_cltk
'
)
lemmatizer
=
BackoffLatinLemmatizer
()
lemmatizer
=
BackoffLatinLemmatizer
()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
text
=
'
Hoc igitur ius nostrum constat aut ex scripto aut sine scripto, ut apud Graecos: τῶν νόμων οἱ μὲν ἔγγραφοι, οἱ δὲ ἄγραφοι .
'
text
=
'
Hoc igitur ius nostrum constat aut ex scripto aut sine scripto, ut apud Graecos: τῶν νόμων οἱ μὲν ἔγγραφοι, οἱ δὲ ἄγραφοι .
'
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
re
import
re
punctuation
=
r
"
[\"#$%&\'()*+,-/:;<=>@[\]^_`{|}~.?!«»]
"
punctuation
=
r
"
[\"#$%&\'()*+,-/:;<=>@[\]^_`{|}~.?!«»]
"
new_text
=
''
.
join
([
""
if
ord
(
i
)
<
32
or
ord
(
i
)
>
126
else
i
for
i
in
text
])
new_text
=
''
.
join
([
""
if
ord
(
i
)
<
32
or
ord
(
i
)
>
126
else
i
for
i
in
text
])
text_no_punct
=
re
.
sub
(
punctuation
,
''
,
new_text
)
text_no_punct
=
re
.
sub
(
punctuation
,
''
,
new_text
)
text_one_white_space
=
re
.
sub
(
r
"
\s{2,}
"
,
'
'
,
text_no_punct
)
text_one_white_space
=
re
.
sub
(
r
"
\s{2,}
"
,
'
'
,
text_no_punct
)
text_no_trailing_space
=
text_one_white_space
.
strip
()
text_no_trailing_space
=
text_one_white_space
.
strip
()
text_lower
=
text_no_trailing_space
.
lower
()
text_lower
=
text_no_trailing_space
.
lower
()
print
(
text_lower
)
print
(
text_lower
)
```
```
%% Output
%% Output
hoc igitur ius nostrum constat aut ex scripto aut sine scripto ut apud graecos
hoc igitur ius nostrum constat aut ex scripto aut sine scripto ut apud graecos
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
text_split
=
text_lower
.
split
(
'
'
)
text_split
=
text_lower
.
split
(
'
'
)
print
(
text_split
)
print
(
text_split
)
```
```
%% Output
%% Output
['hoc', 'igitur', 'ius', 'nostrum', 'constat', 'aut', 'ex', 'scripto', 'aut', 'sine', 'scripto', 'ut', 'apud', 'graecos']
['hoc', 'igitur', 'ius', 'nostrum', 'constat', 'aut', 'ex', 'scripto', 'aut', 'sine', 'scripto', 'ut', 'apud', 'graecos']
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
lemmas
=
lemmatizer
.
lemmatize
(
text_split
)
lemmas
=
lemmatizer
.
lemmatize
(
text_split
)
print
(
lemmas
)
print
(
lemmas
)
```
```
%% Output
%% Output
[('hoc', 'hic'), ('igitur', 'igitur'), ('ius', 'ius'), ('nostrum', 'nos'), ('constat', 'consto'), ('aut', 'aut'), ('ex', 'ex'), ('scripto', 'scribo'), ('aut', 'aut'), ('sine', 'sine'), ('scripto', 'scribo'), ('ut', 'ut'), ('apud', 'apud'), ('graecos', 'graecus')]
[('hoc', 'hic'), ('igitur', 'igitur'), ('ius', 'ius'), ('nostrum', 'nos'), ('constat', 'consto'), ('aut', 'aut'), ('ex', 'ex'), ('scripto', 'scribo'), ('aut', 'aut'), ('sine', 'sine'), ('scripto', 'scribo'), ('ut', 'ut'), ('apud', 'apud'), ('graecos', 'graecus')]
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
pandas
as
pd
import
pandas
as
pd
path_stoplist
=
'
/home/mribary/
Dropbox
/py
D
igest/dump/D_stoplist_001.txt
'
path_stoplist
=
'
/home/mribary/
OneDrive/Git
/py
d
igest/dump/D_stoplist_001.txt
'
stopwords
=
list
(
pd
.
read_csv
(
path_stoplist
,
header
=
None
)[
0
])
# 57 custom stopwords
stopwords
=
list
(
pd
.
read_csv
(
path_stoplist
,
header
=
None
)[
0
])
# 57 custom stopwords
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
textunit
=
''
textunit
=
''
for
y
in
range
(
len
(
lemmas
)):
for
y
in
range
(
len
(
lemmas
)):
if
stopwords
is
not
None
:
if
stopwords
is
not
None
:
if
lemmas
[
y
][
1
]
not
in
stopwords
:
if
lemmas
[
y
][
1
]
not
in
stopwords
:
textunit
=
textunit
+
str
(
lemmas
[
y
][
1
]
+
'
'
)
textunit
=
textunit
+
str
(
lemmas
[
y
][
1
]
+
'
'
)
else
:
else
:
textunit
=
textunit
+
str
(
lemmas
[
y
][
1
]
+
'
'
)
textunit
=
textunit
+
str
(
lemmas
[
y
][
1
]
+
'
'
)
textunit
=
textunit
.
strip
()
textunit
=
textunit
.
strip
()
print
(
textunit
)
print
(
textunit
)
```
```
%% Output
%% Output
igitur ius nos consto scribo scribo apud graecus
igitur ius nos consto scribo scribo apud graecus
%% Cell type:code id: tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
0 → 100644
+
11
−
0
View file @
0dcabd82
cltk
==0.1.117
fasttext
==0.9.2
gensim
==3.8.3
matplotlib
==3.2.1
nltk
==3.5
numpy
==1.18.4
pandas
==1.0.3
regex
==2020.4.4
scikit-learn
==0.22.2.post1
scipy
==1.4.1
seaborn
==0.10.1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment