natlangproc 1.0.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.
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: natlangproc
3
+ Version: 1.0.0
4
+ Summary: Package for NLP (Natural Language Processing) in Python
5
+ Home-page: https://www.paypal.com/paypalme/mathgamepy
6
+ Author: Aliou Diouf
7
+ Author-email: aliou.diouf5@gmail.com
8
+ License: Diouf Tech
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: License :: Free To Use But Restricted
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENCE.txt
14
+ Requires-Dist: flake8
15
+ Requires-Dist: pytest
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license
23
+ Dynamic: license-file
24
+ Dynamic: requires-dist
25
+ Dynamic: summary
26
+
27
+ Package for NLP (Natural Language Processing) in Python
@@ -0,0 +1,10 @@
1
+ natlangproc-1.0.0.dist-info/licenses/LICENCE.txt,sha256=aTG04wz7HmSamTxE3F5zQCx_S1fXfQzqy2VLjq8G9JI,1170
2
+ py_nlp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ py_nlp/data/inputs/en_stopwords_list.py,sha256=eplz1ZA_BmXWF5xujl4rOzalt-d1p6iUmxuXhmhodfU,201
4
+ py_nlp/data/inputs/fr_stopwords_list.py,sha256=TOv8-g32DXXL5aNq9Ze4jHyhoP6Sj1fOvorixLGRHWQ,363
5
+ py_nlp/src/text_keywords.py,sha256=32LmT1nWnDfawY1GxX2jN3lM9Ym1UUHp-m442Jq2klo,3444
6
+ py_nlp/tests/test_text_keywords.py,sha256=kW8flY4GZwuon9SONwAbcC_xd5H3zLTUYfMhbsq3n1I,2863
7
+ natlangproc-1.0.0.dist-info/METADATA,sha256=ahVp0m_IwU0qhrpKLcPbZrMzm3ie9wpOEbC0-aUHYj4,786
8
+ natlangproc-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
9
+ natlangproc-1.0.0.dist-info/top_level.txt,sha256=SsRVIRUPRN1NT4kj5fhYnoCrf1omlFjk96bLL7jHFKY,7
10
+ natlangproc-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2026 Diouf Tech
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ Quote Diouf Tech in any of your work using this package, or PayPal us :
14
+ https://www.paypal.com/paypalme/mathgamepy
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ py_nlp
py_nlp/__init__.py ADDED
File without changes
@@ -0,0 +1,6 @@
1
+ # This is just to get a clue. Create your own list.
2
+
3
+ [
4
+ 'the', 'Your', 'the', 'of', 'and', 'i', 'prime', 'on', '-', 'to', 'in',
5
+ 'my', 'how', 'you', 'also', 'a', 'if', 'have', 'is', 'an', 'it'
6
+ ]
@@ -0,0 +1,8 @@
1
+ # This is not enough, it is just to get a clue. Create your own list.
2
+
3
+ [
4
+ 'de', 'et', 'les', 'le', 'est', 'par', 'en', 'la', 'ã', 'plus', 'elle',
5
+ 'qui', 'ses', 'à', 'a', 'tous', 'pour', 'cette', 'du', 'des', 'sur', 'ne',
6
+ 'ce', 'sont', 'au', 'dans', 'un', 'sera', 'eux,', 'que', 'leurs', 'avec',
7
+ 'ces', 'ça', 'leur', 'une', 'soit', 'ils', 'il'
8
+ ]
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ r"""
4
+ Keywords from French or English text
5
+ /!\ This script will never be better than human brain
6
+ Author: Aliou Diouf - Master degree in Applied Mathematics,
7
+ speciality Scientific Computing (Numerical Analysis, PDE, Software Engineering,
8
+ Images processing, Signal processing, Aerospace, HR, English...)
9
+ from Paul Sabatier Toulouse 3 University,
10
+ CEO and Founder of Diouf Tech, a STEM company headquartered in Paris (75014)
11
+ Products: www.mathgame-py.com, https://www.paypal.com/paypalme/mathgamepy
12
+ Facebook page: https://www.facebook.com/profile.php?id=100086476192955
13
+ Personal Facebook: https://www.facebook.com/aliou.diouf.587/
14
+ LinkedIn: https://www.linkedin.com/in/aliou-diouf-7b980441b/
15
+ STEM stands for: Science, Technology, Engineering, Mathematics
16
+ My PyPI packages:
17
+ https://pypi.org/project/py-ci-cd,
18
+ https://pypi.org/project/pymeshing
19
+ https://pypi.org/project/passwordworld
20
+ https://pypi.org/project/py-num-math/
21
+ """
22
+
23
+ import os
24
+ from sys import argv
25
+ from string import punctuation
26
+
27
+
28
+ def text_keywords(text, sort=False, nb_keywords=None):
29
+ """Provides the most relevant keywords of text"""
30
+
31
+ text_lower = text.lower()
32
+ dir_path = os.path.dirname(os.path.realpath(__file__))
33
+ inputs = os.path.join(dir_path, '../data/inputs')
34
+
35
+ # You may review these conditions
36
+ if 'é' in text_lower or 'è' in text_lower or 'ê' in text_lower \
37
+ or 'ù' in text_lower or 'î' in text_lower or 'ï' in text_lower \
38
+ or 'û' in text_lower or 'à' in text_lower or 'â' in text_lower \
39
+ or 'une ' in text_lower or 'il ' in text_lower \
40
+ or 'elle ' in text_lower:
41
+ stopwords_filename = 'fr_stopwords_list.py'
42
+ else:
43
+ # Default is English
44
+ stopwords_filename = 'en_stopwords_list.py'
45
+
46
+ with open(os.path.join(inputs, stopwords_filename), encoding='utf-8') as f:
47
+ stopwords = eval(f.read())
48
+ words_dict = {}
49
+
50
+ for item in text_lower.split():
51
+ try:
52
+ word = item.split("'")[1]
53
+ except IndexError:
54
+ word = item
55
+ word = word.translate(str.maketrans('', '', punctuation)).strip()
56
+ if word and word not in stopwords:
57
+ words_dict[word] = words_dict.get(word, 0) + 1
58
+
59
+ if sort:
60
+ sorted_tuples_list = sorted(words_dict.items(), key=lambda tup: tup[1],
61
+ reverse=True)
62
+ if nb_keywords:
63
+ return [t[0] for t in sorted_tuples_list[:nb_keywords]]
64
+ else:
65
+ return sorted_tuples_list
66
+
67
+ return list(words_dict.items())
68
+
69
+
70
+ def usage():
71
+ """Usage for main program"""
72
+
73
+ print(f'Usage: {argv[0]} sort-nb_most_relevant_words filename_abs_path\n')
74
+ exit()
75
+
76
+
77
+ if __name__ == '__main__':
78
+
79
+ print()
80
+
81
+ if '--help' in argv or '-h' in argv:
82
+ usage()
83
+
84
+ try:
85
+ text_filename = argv[1]
86
+ except IndexError:
87
+ usage()
88
+
89
+ with open(text_filename, encoding='utf-8') as f:
90
+ text = f.read()
91
+
92
+ for arg in argv:
93
+ if 'sort' in arg:
94
+ sort = True
95
+ try:
96
+ nb_keywords = int(arg.split('-')[1])
97
+ print(text_keywords(text, sort, nb_keywords), '\n')
98
+ except (IndexError, ValueError):
99
+ print(text_keywords(text, sort), '\n')
100
+ exit()
101
+
102
+ keywords_list = text_keywords(text)
103
+ print(f'{keywords_list}')
104
+ print('\nnb_keywords =', len(keywords_list))
105
+
106
+ print()
@@ -0,0 +1,79 @@
1
+ """
2
+ Tests text_keywords
3
+ These are minimal tests.
4
+ You can add more tests or execute the main program of text_keywords
5
+ Author: Aliou Diouf - Master degree in Applied Mathematics,
6
+ speciality Scientific Computing (Numerical Analysis, PDE, Software Engineering,
7
+ Images processing, Signal processing, Aerospace, HR, English...)
8
+ from Paul Sabatier Toulouse 3 University,
9
+ CEO and Founder of Diouf Tech, a STEM company headquartered in Paris (75014)
10
+ Products: www.mathgame-py.com, https://www.paypal.com/paypalme/mathgamepy
11
+ Facebook page: https://www.facebook.com/profile.php?id=100086476192955
12
+ Personal Facebook: https://www.facebook.com/aliou.diouf.587/
13
+ LinkedIn: https://www.linkedin.com/in/aliou-diouf-7b980441b/
14
+ STEM stands for: Science, Technology, Engineering, Mathematics
15
+ My PyPI packages:
16
+ https://pypi.org/project/py-ci-cd,
17
+ https://pypi.org/project/pymeshing
18
+ https://pypi.org/project/passwordworld
19
+ https://pypi.org/project/py-num-math/
20
+ """
21
+
22
+ from py_nlp.src.text_keywords import text_keywords
23
+
24
+
25
+ def test_text_keywords_without_sort_en():
26
+ """Unit test of text_keywords, without sort", English version"""
27
+
28
+ text = 'It tests "text keywords" function'
29
+ expected = [('tests', 1), ('text', 1), ('keywords', 1), ('function', 1)]
30
+
31
+ assert text_keywords(text) == expected
32
+
33
+
34
+ def test_text_keywords_with_sort_without_nb_keywords_en():
35
+ """Unit test of text_keywords,with sort but without nb_keywords, English"""
36
+
37
+ text = 'Work, work, work, work, and work smartly'
38
+ expected = [('work', 5), ('smartly', 1)]
39
+
40
+ assert text_keywords(text, sort=True) == expected
41
+
42
+
43
+ def test_text_keywords_with_sort_and_nb_keywords_en():
44
+ """Unit test of text_keywords with sort and nb_keywords, English version"""
45
+
46
+ text = 'Work, work, work, work, and work smartly'
47
+ expected = ['work']
48
+
49
+ assert text_keywords(text, sort=True, nb_keywords=1) == expected
50
+
51
+
52
+ def test_text_keywords_without_sort_fr():
53
+ """Unit test of text_keywords, without sort, French version"""
54
+
55
+ text = 'Il teste "text keywords" fonction'
56
+ expected = [('teste', 1), ('text', 1), ('keywords', 1), ('fonction', 1)]
57
+
58
+ assert text_keywords(text) == expected
59
+
60
+
61
+ def test_text_keywords_with_sort_without_nb_keywords_fr():
62
+ """Unit test of text_keywords,with sort but without nb_keywords"""
63
+
64
+ text = 'Travailler, beaucoup travailler, toujours travailler,' \
65
+ ' encore travailler'
66
+ expected = [('travailler', 4), ('beaucoup', 1), ('toujours', 1),
67
+ ('encore', 1)]
68
+
69
+ assert text_keywords(text, sort=True) == expected
70
+
71
+
72
+ def test_text_keywords_with_sort_and_nb_keywords_fr():
73
+ """Unit test of text_keywords with sort and nb_keywords"""
74
+
75
+ text = 'Travailler, beaucoup travailler, toujours travailler,' \
76
+ ' encore travailler'
77
+ expected = ['travailler']
78
+
79
+ assert text_keywords(text, sort=True, nb_keywords=1) == expected