textalyzer 0.2.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,82 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Wed Jan 18 04:19:37 2017
4
+
5
+ @author: lord
6
+ """
7
+
8
+ import re
9
+
10
+ from nltk.corpus import wordnet
11
+
12
+ replacement_patterns = [
13
+ (r'isn\'t', 'is not'),
14
+ (r'won\'t', 'will not'),
15
+ (r'can\'t', 'cannot'),
16
+ (r'Can\'t', 'Can not'),
17
+ (r'don\'t', 'do not'),
18
+ (r'Don\'t', 'Do not'),
19
+ (r'it\'s', 'it is'),
20
+ (r'It\'s', 'It is'),
21
+ (r'shan\'t', 'shall not'),
22
+ (r'Shan\'t', 'Shall not'),
23
+ (r'i\'m', 'i am'),
24
+ (r'I\'m', 'I am'),
25
+ (r'ain\'t', 'is not'),
26
+ (r'Ain\'t', 'Is not'),
27
+ (r'you\'re', 'you are'),
28
+ (r'You\'re', 'You are'),
29
+ (r'aren\'t', 'Are not'),
30
+ (r'Aren\'t', 'Are not'),
31
+ (r'\\n\\n', '\n'),
32
+ (r'\\n', '\n'),
33
+ (r'\'', ''),
34
+ (r'\\r\n', '\n'),
35
+ (r'\\r', ''),
36
+ (r'/', ' '),
37
+ (r'\[', ''),
38
+ (r'\{', ''),
39
+ (r'\}', ''),
40
+ (r'\]', ''),
41
+ (r':', ''),
42
+ (r'data', ''),
43
+ (r'Anonymous', ''),
44
+ (r'(\w+)\'ll', '\g<1> will'),
45
+ (r'(\w+)n\'t', '\g<1> not'),
46
+ (r'(\w+)\'ve', '\g<1> have'),
47
+ (r'(\w+)\'s', '\g<1> is'),
48
+ (r'(\w+)\'re', '\g<1> are'),
49
+ (r'(\w+)\'r', '\g<1> are'),
50
+ (r'(\w+)\'d', '\g<1> would'),
51
+ ]
52
+
53
+ # Class for replacing characters
54
+ class ContractionReplacers(object):
55
+ def __init__(self, patterns=None):
56
+ if patterns is None:
57
+ patterns = replacement_patterns
58
+ patterns = list(patterns)
59
+ self.patterns = [(re.compile(regex, flags=re.I), repl) for (regex, repl) in patterns]
60
+
61
+ def text_replacers(self, text):
62
+ s = text
63
+ for (pattern, repl) in self.patterns:
64
+ (s, count) = re.subn(pattern, repl, s)
65
+ return s
66
+
67
+
68
+ # Class for removing repeating characters
69
+ class RepeatingReplacers(object):
70
+ def __init__(self, corpus=wordnet):
71
+ self.corpus = corpus
72
+ self.repeat_regexp = re.compile(r'(\w*)(\w)\2(\w*)')
73
+ self.repl = r'\1\2\3'
74
+
75
+ def text_repeaters(self, word):
76
+ if self.corpus.synsets(word):
77
+ return word
78
+ repl_word = self.repeat_regexp.sub(self.repl, word)
79
+ if repl_word != word:
80
+ return self.text_repeaters(repl_word)
81
+ else:
82
+ return repl_word
textalyzer/__init__.py ADDED
@@ -0,0 +1,9 @@
1
+ # Developer : LORD KAY
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.
8
+
9
+ from __future__ import absolute_import, division, print_function
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: textalyzer
3
+ Version: 0.2.0
4
+ Summary: A text analyzer for repeating and contraction characters
5
+ Home-page: https://github.com/LORD-KAY/Textalyzer
6
+ Download-URL: https://github.com/LORD-KAY/Textalyzer/archive/refs/tags/v0.2.0.tar.gz
7
+ Author: Lord Kay
8
+ Author-email: offeilord@gmail.com
9
+ License: MIT
10
+ Project-URL: Source, https://github.com/LORD-KAY/Textalyzer
11
+ Keywords: python,replacers,words,repeat,characters
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE.txt
19
+ Requires-Dist: nltk>=3
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: download-url
26
+ Dynamic: home-page
27
+ Dynamic: keywords
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: project-url
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ # Textalyzer
36
+ Textalyzer is a lightweight python module or library to help ease analyzing of text or words in a particular sentence and manipulating it.
37
+ Textalyzer analyzes repeating words and contracted words or contractions.
38
+
39
+ # Class Functions Involved in this module
40
+ [-] ContractionReplacers <br>
41
+ [-] RepeatingReplacers
42
+
43
+ # Usage
44
+ -Place the file in a folder where you have either read or write and read permisson. Eg. /opinionmining/lib/Textalyzer.py<br/>
45
+ -Import the module into your application.<br/>
46
+ <hr/>
47
+ from opinionmining.lib.Textalyzer import "Function To Use" <br>
48
+ sample = "I can't wait for the football match" <br>
49
+ object = ContractionReplacers() <br>
50
+ data = object.text_replacers(sample)<br>
51
+
52
+ # Sample
53
+ ## Repeating words
54
+ - Repeating words like helloooooooooooo - textalyzer help format this word by removing the o's to its normal word "hello"<br/>
55
+ - Contractions like I'm - Textalyzer help format this word by converting it to it's normal word "I am"
56
+ # Dependencies
57
+ - nltk
58
+ - Download the WordNet corpus before using `RepeatingReplacers`: `python -m nltk.downloader wordnet`
59
+ # PyPI
60
+ - Textalyzer is available at python package index.
61
+ ## Installation Guide
62
+ - Download textalyzer using pip<br>
63
+ - pip install textalyzer<br>
64
+ - Import textalyzer into your project by using ```from textalyzer import Textalyzer``` depending on the function you want to use.<br>
65
+ - Then use ```replacer = Textalyzer.ContractionReplacers()``` and ```repeat = Textalyzer.RepeatingReplacers()``` <br>
66
+    - ## Or
67
+ - Simple do ```import textalyzer``` <br>
68
+ - Then Use ``` data = textalyzer.Textalyzer ``` <br>
69
+ - ``` replacer = data.ContractionReplacers() ``` <br>
70
+
71
+ ## Alternatively
72
+ - [x] You can download the tarball file from `pypi.python.org/pypi/textalyzer`
73
+ - [x] Extract the tarball file
74
+ - [x] Navigate into the extracted folder and install using `python setup.py install`
75
+
76
+ **To Check Whether it's installed**
77
+ - type `pip freeze` to display the list of installed packages
78
+ # Why This
79
+ - Textalyzer is mostly used by python programmers who are more involved with Natural Language Processing , Machine Learning, Text Extraction and others.
@@ -0,0 +1,7 @@
1
+ textalyzer/Textalyzer.py,sha256=PFN0MGn2qOK_mlp1ItCYSBMtnGttNqZrFOXTLLzeGFg,2121
2
+ textalyzer/__init__.py,sha256=5WLSQ9h-m7dFdC28l8nXvMTsfjCojL7Uggjjr5H-4Yw,425
3
+ textalyzer-0.2.0.dist-info/licenses/LICENSE.txt,sha256=OTAFEvyRVzwgK6ViyjvpQVaZFDzhI2pFCGcE3L9qrX0,1065
4
+ textalyzer-0.2.0.dist-info/METADATA,sha256=sRx0aD-V965nho9KBUNM3ghBjyhMg8Ry9QrXae9hp4M,3245
5
+ textalyzer-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ textalyzer-0.2.0.dist-info/top_level.txt,sha256=Vg5tngIh2SweYsldYYulvgcyDrncTxZ8ZHSipP2DAkw,11
7
+ textalyzer-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Lord Kay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ textalyzer