webscout 8.2.6__py3-none-any.whl → 8.2.8__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.

Potentially problematic release.


This version of webscout might be problematic. Click here for more details.

Files changed (150) hide show
  1. webscout/AIauto.py +1 -1
  2. webscout/AIutel.py +298 -239
  3. webscout/Extra/Act.md +309 -0
  4. webscout/Extra/GitToolkit/gitapi/README.md +110 -0
  5. webscout/Extra/YTToolkit/README.md +375 -0
  6. webscout/Extra/YTToolkit/ytapi/README.md +44 -0
  7. webscout/Extra/YTToolkit/ytapi/extras.py +92 -19
  8. webscout/Extra/autocoder/autocoder.py +309 -114
  9. webscout/Extra/autocoder/autocoder_utiles.py +15 -15
  10. webscout/Extra/gguf.md +430 -0
  11. webscout/Extra/tempmail/README.md +488 -0
  12. webscout/Extra/weather.md +281 -0
  13. webscout/Litlogger/Readme.md +175 -0
  14. webscout/Provider/AISEARCH/DeepFind.py +41 -37
  15. webscout/Provider/AISEARCH/README.md +279 -0
  16. webscout/Provider/AISEARCH/__init__.py +0 -1
  17. webscout/Provider/AISEARCH/genspark_search.py +228 -86
  18. webscout/Provider/AISEARCH/hika_search.py +11 -11
  19. webscout/Provider/AISEARCH/scira_search.py +324 -322
  20. webscout/Provider/AllenAI.py +7 -14
  21. webscout/Provider/Blackboxai.py +518 -74
  22. webscout/Provider/Cloudflare.py +0 -1
  23. webscout/Provider/Deepinfra.py +23 -21
  24. webscout/Provider/Flowith.py +217 -0
  25. webscout/Provider/FreeGemini.py +250 -0
  26. webscout/Provider/GizAI.py +15 -5
  27. webscout/Provider/Glider.py +11 -8
  28. webscout/Provider/HeckAI.py +80 -52
  29. webscout/Provider/Koboldai.py +7 -4
  30. webscout/Provider/LambdaChat.py +2 -2
  31. webscout/Provider/Marcus.py +10 -18
  32. webscout/Provider/OPENAI/BLACKBOXAI.py +735 -0
  33. webscout/Provider/OPENAI/Cloudflare.py +378 -0
  34. webscout/Provider/OPENAI/FreeGemini.py +282 -0
  35. webscout/Provider/OPENAI/NEMOTRON.py +244 -0
  36. webscout/Provider/OPENAI/README.md +1253 -0
  37. webscout/Provider/OPENAI/__init__.py +8 -0
  38. webscout/Provider/OPENAI/ai4chat.py +293 -286
  39. webscout/Provider/OPENAI/api.py +810 -0
  40. webscout/Provider/OPENAI/base.py +217 -14
  41. webscout/Provider/OPENAI/c4ai.py +373 -367
  42. webscout/Provider/OPENAI/chatgpt.py +7 -0
  43. webscout/Provider/OPENAI/chatgptclone.py +7 -0
  44. webscout/Provider/OPENAI/chatsandbox.py +172 -0
  45. webscout/Provider/OPENAI/deepinfra.py +30 -20
  46. webscout/Provider/OPENAI/e2b.py +6 -0
  47. webscout/Provider/OPENAI/exaai.py +7 -0
  48. webscout/Provider/OPENAI/exachat.py +6 -0
  49. webscout/Provider/OPENAI/flowith.py +162 -0
  50. webscout/Provider/OPENAI/freeaichat.py +359 -352
  51. webscout/Provider/OPENAI/glider.py +323 -316
  52. webscout/Provider/OPENAI/groq.py +361 -354
  53. webscout/Provider/OPENAI/heckai.py +30 -64
  54. webscout/Provider/OPENAI/llmchatco.py +8 -0
  55. webscout/Provider/OPENAI/mcpcore.py +7 -0
  56. webscout/Provider/OPENAI/multichat.py +8 -0
  57. webscout/Provider/OPENAI/netwrck.py +356 -350
  58. webscout/Provider/OPENAI/opkfc.py +8 -0
  59. webscout/Provider/OPENAI/scirachat.py +471 -462
  60. webscout/Provider/OPENAI/sonus.py +9 -0
  61. webscout/Provider/OPENAI/standardinput.py +9 -1
  62. webscout/Provider/OPENAI/textpollinations.py +339 -329
  63. webscout/Provider/OPENAI/toolbaz.py +7 -0
  64. webscout/Provider/OPENAI/typefully.py +355 -0
  65. webscout/Provider/OPENAI/typegpt.py +358 -346
  66. webscout/Provider/OPENAI/uncovrAI.py +7 -0
  67. webscout/Provider/OPENAI/utils.py +103 -7
  68. webscout/Provider/OPENAI/venice.py +12 -0
  69. webscout/Provider/OPENAI/wisecat.py +19 -19
  70. webscout/Provider/OPENAI/writecream.py +7 -0
  71. webscout/Provider/OPENAI/x0gpt.py +7 -0
  72. webscout/Provider/OPENAI/yep.py +50 -21
  73. webscout/Provider/OpenGPT.py +1 -1
  74. webscout/Provider/TTI/AiForce/README.md +159 -0
  75. webscout/Provider/TTI/FreeAIPlayground/README.md +99 -0
  76. webscout/Provider/TTI/ImgSys/README.md +174 -0
  77. webscout/Provider/TTI/MagicStudio/README.md +101 -0
  78. webscout/Provider/TTI/Nexra/README.md +155 -0
  79. webscout/Provider/TTI/PollinationsAI/README.md +146 -0
  80. webscout/Provider/TTI/README.md +128 -0
  81. webscout/Provider/TTI/aiarta/README.md +134 -0
  82. webscout/Provider/TTI/artbit/README.md +100 -0
  83. webscout/Provider/TTI/fastflux/README.md +129 -0
  84. webscout/Provider/TTI/huggingface/README.md +114 -0
  85. webscout/Provider/TTI/piclumen/README.md +161 -0
  86. webscout/Provider/TTI/pixelmuse/README.md +79 -0
  87. webscout/Provider/TTI/talkai/README.md +139 -0
  88. webscout/Provider/TTS/README.md +192 -0
  89. webscout/Provider/TTS/__init__.py +2 -1
  90. webscout/Provider/TTS/speechma.py +500 -100
  91. webscout/Provider/TTS/sthir.py +94 -0
  92. webscout/Provider/TeachAnything.py +3 -7
  93. webscout/Provider/TextPollinationsAI.py +4 -2
  94. webscout/Provider/{aimathgpt.py → UNFINISHED/ChatHub.py} +88 -68
  95. webscout/Provider/UNFINISHED/liner_api_request.py +263 -0
  96. webscout/Provider/UNFINISHED/oivscode.py +351 -0
  97. webscout/Provider/UNFINISHED/test_lmarena.py +119 -0
  98. webscout/Provider/Writecream.py +11 -2
  99. webscout/Provider/__init__.py +8 -14
  100. webscout/Provider/ai4chat.py +4 -58
  101. webscout/Provider/asksteve.py +17 -9
  102. webscout/Provider/cerebras.py +3 -1
  103. webscout/Provider/koala.py +170 -268
  104. webscout/Provider/llmchat.py +3 -0
  105. webscout/Provider/lmarena.py +198 -0
  106. webscout/Provider/meta.py +7 -4
  107. webscout/Provider/samurai.py +223 -0
  108. webscout/Provider/scira_chat.py +4 -2
  109. webscout/Provider/typefully.py +23 -151
  110. webscout/__init__.py +4 -2
  111. webscout/cli.py +3 -28
  112. webscout/conversation.py +35 -35
  113. webscout/litagent/Readme.md +276 -0
  114. webscout/scout/README.md +402 -0
  115. webscout/swiftcli/Readme.md +323 -0
  116. webscout/version.py +1 -1
  117. webscout/webscout_search.py +2 -182
  118. webscout/webscout_search_async.py +1 -179
  119. webscout/zeroart/README.md +89 -0
  120. webscout/zeroart/__init__.py +134 -54
  121. webscout/zeroart/base.py +19 -13
  122. webscout/zeroart/effects.py +101 -99
  123. webscout/zeroart/fonts.py +1239 -816
  124. {webscout-8.2.6.dist-info → webscout-8.2.8.dist-info}/METADATA +116 -74
  125. {webscout-8.2.6.dist-info → webscout-8.2.8.dist-info}/RECORD +130 -103
  126. {webscout-8.2.6.dist-info → webscout-8.2.8.dist-info}/WHEEL +1 -1
  127. webscout-8.2.8.dist-info/entry_points.txt +3 -0
  128. webscout-8.2.8.dist-info/top_level.txt +1 -0
  129. webscout/Provider/AISEARCH/ISou.py +0 -256
  130. webscout/Provider/ElectronHub.py +0 -773
  131. webscout/Provider/Free2GPT.py +0 -241
  132. webscout/Provider/GPTWeb.py +0 -249
  133. webscout/Provider/bagoodex.py +0 -145
  134. webscout/Provider/geminiprorealtime.py +0 -160
  135. webscout/scout/core.py +0 -881
  136. webscout-8.2.6.dist-info/entry_points.txt +0 -3
  137. webscout-8.2.6.dist-info/top_level.txt +0 -2
  138. webstoken/__init__.py +0 -30
  139. webstoken/classifier.py +0 -189
  140. webstoken/keywords.py +0 -216
  141. webstoken/language.py +0 -128
  142. webstoken/ner.py +0 -164
  143. webstoken/normalizer.py +0 -35
  144. webstoken/processor.py +0 -77
  145. webstoken/sentiment.py +0 -206
  146. webstoken/stemmer.py +0 -73
  147. webstoken/tagger.py +0 -60
  148. webstoken/tokenizer.py +0 -158
  149. /webscout/Provider/{Youchat.py → UNFINISHED/Youchat.py} +0 -0
  150. {webscout-8.2.6.dist-info → webscout-8.2.8.dist-info}/licenses/LICENSE.md +0 -0
webstoken/ner.py DELETED
@@ -1,164 +0,0 @@
1
- """
2
- Named Entity Recognition (NER) module for identifying and classifying named entities.
3
- """
4
-
5
- from typing import List, Tuple, Dict, Set
6
- import re
7
-
8
-
9
- class NamedEntityRecognizer:
10
- """Rule-based Named Entity Recognition."""
11
-
12
- def __init__(self):
13
- # Common entity patterns
14
- self.PERSON_TITLES = {
15
- 'mr', 'mrs', 'ms', 'miss', 'dr', 'prof', 'sir', 'madam',
16
- 'lord', 'lady', 'president', 'ceo', 'director'
17
- }
18
-
19
- self.ORGANIZATION_SUFFIXES = {
20
- 'inc', 'corp', 'ltd', 'llc', 'company', 'corporation',
21
- 'associates', 'partners', 'foundation', 'institute'
22
- }
23
-
24
- self.LOCATION_INDICATORS = {
25
- 'street', 'road', 'avenue', 'boulevard', 'lane', 'drive',
26
- 'circle', 'square', 'park', 'bridge', 'river', 'lake',
27
- 'mountain', 'forest', 'city', 'town', 'village', 'country'
28
- }
29
-
30
- self.DATE_MONTHS = {
31
- 'january', 'february', 'march', 'april', 'may', 'june',
32
- 'july', 'august', 'september', 'october', 'november', 'december'
33
- }
34
-
35
- # Compile regex patterns
36
- self.patterns = {
37
- 'EMAIL': re.compile(r'\b[\w\.-]+@[\w\.-]+\.\w+\b'),
38
- 'URL': re.compile(r'https?://(?:[\w-]|(?:%[\da-fA-F]{2}))+'),
39
- 'PHONE': re.compile(r'\+?\d{1,3}[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}'),
40
- 'DATE': re.compile(r'\b\d{1,2}[-/]\d{1,2}[-/]\d{2,4}\b|\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]* \d{1,2},? \d{4}\b'),
41
- 'TIME': re.compile(r'\b\d{1,2}:\d{2}(?::\d{2})?(?:\s*[AaPp][Mm])?\b'),
42
- 'MONEY': re.compile(r'\$\d+(?:,\d{3})*(?:\.\d{2})?|\d+(?:,\d{3})*(?:\.\d{2})?\s*(?:dollars|USD|EUR|GBP)'),
43
- 'PERCENTAGE': re.compile(r'\b\d+(?:\.\d+)?%\b')
44
- }
45
-
46
- def is_capitalized(self, word: str) -> bool:
47
- """Check if a word is capitalized."""
48
- return word and word[0].isupper()
49
-
50
- def extract_entities(self, text: str) -> Dict[str, List[Tuple[str, str]]]:
51
- """
52
- Extract named entities from text.
53
-
54
- Returns:
55
- Dict mapping entity types to list of (text, label) tuples
56
- """
57
- entities = {
58
- 'PERSON': [],
59
- 'ORGANIZATION': [],
60
- 'LOCATION': [],
61
- 'DATE': [],
62
- 'TIME': [],
63
- 'MONEY': [],
64
- 'EMAIL': [],
65
- 'URL': [],
66
- 'PHONE': [],
67
- 'PERCENTAGE': []
68
- }
69
-
70
- # First find regex pattern matches
71
- for label, pattern in self.patterns.items():
72
- for match in pattern.finditer(text):
73
- entities[label].append((match.group(), label))
74
-
75
- # Process text word by word for other entities
76
- words = text.split()
77
- i = 0
78
- while i < len(words):
79
- word = words[i]
80
- next_word = words[i + 1] if i + 1 < len(words) else None
81
-
82
- # Check for person names
83
- if word.lower() in self.PERSON_TITLES and next_word and self.is_capitalized(next_word):
84
- name_parts = []
85
- j = i + 1
86
- while j < len(words) and self.is_capitalized(words[j]):
87
- name_parts.append(words[j])
88
- j += 1
89
- if name_parts:
90
- entities['PERSON'].append((' '.join(name_parts), 'PERSON'))
91
- i = j
92
- continue
93
-
94
- # Check for organizations
95
- if self.is_capitalized(word):
96
- org_parts = [word]
97
- j = i + 1
98
- while j < len(words) and (
99
- self.is_capitalized(words[j]) or
100
- words[j].lower() in self.ORGANIZATION_SUFFIXES
101
- ):
102
- org_parts.append(words[j])
103
- j += 1
104
- if len(org_parts) > 1 or (
105
- len(org_parts) == 1 and
106
- any(suff in word.lower() for suff in self.ORGANIZATION_SUFFIXES)
107
- ):
108
- entities['ORGANIZATION'].append((' '.join(org_parts), 'ORGANIZATION'))
109
- i = j
110
- continue
111
-
112
- # Check for locations
113
- if word.lower() in self.LOCATION_INDICATORS and i > 0:
114
- if self.is_capitalized(words[i - 1]):
115
- entities['LOCATION'].append((words[i - 1] + ' ' + word, 'LOCATION'))
116
-
117
- i += 1
118
-
119
- return entities
120
-
121
- def tag_text(self, text: str) -> List[Tuple[str, str]]:
122
- """
123
- Tag each word in text with its entity type.
124
-
125
- Returns:
126
- List of (word, entity_type) tuples
127
- """
128
- entities = self.extract_entities(text)
129
- tagged = []
130
-
131
- # Create a map of word positions to entity labels
132
- position_labels = {}
133
- text_lower = text.lower()
134
-
135
- for entity_type, entity_list in entities.items():
136
- for entity_text, _ in entity_list:
137
- start = text_lower.find(entity_text.lower())
138
- if start != -1:
139
- end = start + len(entity_text)
140
- for pos in range(start, end):
141
- position_labels[pos] = entity_type
142
-
143
- # Tag each character position
144
- current_pos = 0
145
- current_word = []
146
- current_label = 'O' # Outside any entity
147
-
148
- for char in text:
149
- if char.isspace():
150
- if current_word:
151
- tagged.append((''.join(current_word), current_label))
152
- current_word = []
153
- current_label = 'O'
154
- else:
155
- current_word.append(char)
156
- if current_pos in position_labels:
157
- current_label = position_labels[current_pos]
158
- current_pos += 1
159
-
160
- # Add last word if exists
161
- if current_word:
162
- tagged.append((''.join(current_word), current_label))
163
-
164
- return tagged
webstoken/normalizer.py DELETED
@@ -1,35 +0,0 @@
1
- """
2
- Text normalization utilities.
3
- """
4
-
5
- import re
6
- from typing import List, Set
7
-
8
-
9
- class TextNormalizer:
10
- """Text normalization utilities."""
11
-
12
- def __init__(self):
13
- self.stop_words: Set[str] = {
14
- 'a', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'for', 'from',
15
- 'has', 'he', 'in', 'is', 'it', 'its', 'of', 'on', 'that', 'the',
16
- 'to', 'was', 'were', 'will', 'with'
17
- }
18
-
19
- def remove_stop_words(self, tokens: List[str]) -> List[str]:
20
- """Remove common stop words from token list."""
21
- return [token for token in tokens if token.lower() not in self.stop_words]
22
-
23
- def normalize(self, text: str) -> str:
24
- """Apply various normalization steps to text."""
25
- # Convert to lowercase
26
- text = text.lower()
27
-
28
- # Replace multiple spaces with single space
29
- text = re.sub(r'\s+', ' ', text)
30
-
31
- # Remove special characters except apostrophes within words
32
- text = re.sub(r'[^a-z0-9\s\']', '', text)
33
- text = re.sub(r'\s\'|\'\s', ' ', text)
34
-
35
- return text.strip()
webstoken/processor.py DELETED
@@ -1,77 +0,0 @@
1
- """
2
- Main text processing utilities combining all NLP components.
3
- """
4
-
5
- from typing import Dict, Any, List, Tuple
6
-
7
- from .tokenizer import SentenceTokenizer, WordTokenizer
8
- from .tagger import POSTagger
9
- from .stemmer import Stemmer
10
- from .normalizer import TextNormalizer
11
-
12
-
13
- def process_text(text: str, normalize: bool = True, remove_stops: bool = True) -> Dict[str, Any]:
14
- """
15
- Process text using all available NLP tools.
16
-
17
- Args:
18
- text (str): Input text to process
19
- normalize (bool): Whether to normalize text
20
- remove_stops (bool): Whether to remove stop words
21
-
22
- Returns:
23
- Dict containing processed results with the following structure:
24
- {
25
- 'sentences': [
26
- {
27
- 'original': str, # Original sentence
28
- 'tokens': List[str], # Word tokens
29
- 'pos_tags': List[Tuple[str, str]], # (word, tag) pairs
30
- 'stems': List[Tuple[str, str]] # (word, stem) pairs
31
- },
32
- ...
33
- ],
34
- 'num_sentences': int, # Total number of sentences
35
- 'num_tokens': int # Total number of tokens
36
- }
37
- """
38
- # Initialize tools
39
- sentence_tokenizer = SentenceTokenizer()
40
- word_tokenizer = WordTokenizer()
41
- pos_tagger = POSTagger()
42
- stemmer = Stemmer()
43
- normalizer = TextNormalizer()
44
-
45
- # Process text
46
- if normalize:
47
- text = normalizer.normalize(text)
48
-
49
- # Get sentences
50
- sentences = sentence_tokenizer.tokenize(text)
51
-
52
- # Process each sentence
53
- processed_sentences = []
54
- for sentence in sentences:
55
- # Tokenize words
56
- tokens = word_tokenizer.tokenize(sentence)
57
-
58
- # Remove stop words if requested
59
- if remove_stops:
60
- tokens = normalizer.remove_stop_words(tokens)
61
-
62
- # Get POS tags and stems
63
- tagged = pos_tagger.tag(tokens)
64
- stems = [(token, stemmer.stem(token)) for token, _ in tagged]
65
-
66
- processed_sentences.append({
67
- 'original': sentence,
68
- 'tokens': tokens,
69
- 'pos_tags': tagged,
70
- 'stems': stems
71
- })
72
-
73
- return {
74
- 'sentences': processed_sentences,
75
- 'num_sentences': len(sentences),
76
- 'num_tokens': sum(len(s['tokens']) for s in processed_sentences)
77
- }
webstoken/sentiment.py DELETED
@@ -1,206 +0,0 @@
1
- """
2
- Sentiment analysis module for determining text sentiment and emotion.
3
- """
4
-
5
- from typing import Dict, List, Set, Tuple
6
- import re
7
-
8
- from .tokenizer import WordTokenizer
9
- from .normalizer import TextNormalizer
10
-
11
-
12
- class SentimentAnalyzer:
13
- """Rule-based sentiment analysis using lexicon approach."""
14
-
15
- def __init__(self):
16
- self.word_tokenizer = WordTokenizer()
17
- self.normalizer = TextNormalizer()
18
-
19
- # Sentiment lexicons
20
- self.positive_words: Set[str] = {
21
- 'good', 'great', 'awesome', 'excellent', 'happy', 'wonderful',
22
- 'fantastic', 'amazing', 'love', 'beautiful', 'best', 'perfect',
23
- 'brilliant', 'outstanding', 'superb', 'nice', 'pleasant', 'delightful',
24
- 'positive', 'remarkable', 'terrific', 'incredible', 'enjoyable',
25
- 'favorable', 'marvelous', 'splendid', 'superior', 'worthy', 'right'
26
- }
27
-
28
- self.negative_words: Set[str] = {
29
- 'bad', 'terrible', 'awful', 'horrible', 'sad', 'poor', 'wrong',
30
- 'worse', 'worst', 'hate', 'dislike', 'disappointing', 'negative',
31
- 'inferior', 'useless', 'worthless', 'mediocre', 'inadequate',
32
- 'unpleasant', 'unfavorable', 'disagreeable', 'offensive', 'annoying',
33
- 'frustrating', 'irritating', 'disgusting', 'dreadful', 'pathetic'
34
- }
35
-
36
- # Emotion lexicons
37
- self.emotion_words = {
38
- 'JOY': {
39
- 'happy', 'joyful', 'delighted', 'excited', 'pleased', 'glad',
40
- 'cheerful', 'content', 'satisfied', 'elated', 'jubilant',
41
- 'thrilled', 'ecstatic', 'merry', 'peaceful', 'upbeat'
42
- },
43
- 'SADNESS': {
44
- 'sad', 'unhappy', 'depressed', 'gloomy', 'miserable', 'down',
45
- 'heartbroken', 'disappointed', 'upset', 'distressed', 'grief',
46
- 'sorrow', 'melancholy', 'despair', 'hopeless', 'blue'
47
- },
48
- 'ANGER': {
49
- 'angry', 'mad', 'furious', 'outraged', 'irritated', 'annoyed',
50
- 'frustrated', 'enraged', 'hostile', 'bitter', 'hateful', 'rage',
51
- 'resentful', 'violent', 'aggressive', 'irate'
52
- },
53
- 'FEAR': {
54
- 'afraid', 'scared', 'frightened', 'terrified', 'anxious', 'worried',
55
- 'nervous', 'fearful', 'panicked', 'alarmed', 'horrified', 'dread',
56
- 'uneasy', 'stressed', 'concerned', 'apprehensive'
57
- },
58
- 'SURPRISE': {
59
- 'surprised', 'amazed', 'astonished', 'shocked', 'stunned',
60
- 'startled', 'unexpected', 'incredible', 'unbelievable', 'wonder',
61
- 'awe', 'remarkable', 'mysterious', 'sudden', 'strange'
62
- }
63
- }
64
-
65
- # Intensity modifiers
66
- self.intensifiers = {
67
- 'very': 1.5,
68
- 'really': 1.5,
69
- 'extremely': 2.0,
70
- 'incredibly': 2.0,
71
- 'absolutely': 2.0,
72
- 'totally': 1.5,
73
- 'completely': 1.5,
74
- 'utterly': 2.0,
75
- 'highly': 1.5,
76
- 'especially': 1.5
77
- }
78
-
79
- self.diminishers = {
80
- 'somewhat': 0.5,
81
- 'slightly': 0.5,
82
- 'barely': 0.3,
83
- 'hardly': 0.3,
84
- 'sort of': 0.5,
85
- 'kind of': 0.5,
86
- 'a bit': 0.5,
87
- 'a little': 0.5,
88
- 'not very': 0.3,
89
- 'less': 0.5
90
- }
91
-
92
- # Negation words
93
- self.negation_words = {
94
- 'not', 'no', 'never', 'none', 'nobody', 'nothing', 'neither',
95
- 'nowhere', 'hardly', 'scarcely', 'barely', "don't", "doesn't",
96
- "didn't", "won't", "wouldn't", "shouldn't", "couldn't", "can't"
97
- }
98
-
99
- # Compile patterns
100
- self.word_pattern = re.compile(r'\b\w+\b')
101
-
102
- def _get_window_around_word(self, words: List[str], index: int, window_size: int = 3) -> List[str]:
103
- """Get a window of words around a given index."""
104
- start = max(0, index - window_size)
105
- end = min(len(words), index + window_size + 1)
106
- return words[start:end]
107
-
108
- def _is_negated(self, words: List[str], index: int) -> bool:
109
- """Check if a word is negated by looking at surrounding context."""
110
- window = self._get_window_around_word(words, index)
111
- return any(word in self.negation_words for word in window[:index-window[0]])
112
-
113
- def _get_intensity_multiplier(self, words: List[str], index: int) -> float:
114
- """Get intensity multiplier based on modifiers."""
115
- window = self._get_window_around_word(words, index)
116
- multiplier = 1.0
117
-
118
- for word in window[:index-window[0]]:
119
- if word in self.intensifiers:
120
- multiplier *= self.intensifiers[word]
121
- elif word in self.diminishers:
122
- multiplier *= self.diminishers[word]
123
-
124
- return multiplier
125
-
126
- def analyze_sentiment(self, text: str) -> Dict[str, float]:
127
- """
128
- Analyze sentiment of text.
129
-
130
- Returns:
131
- Dict with sentiment scores:
132
- {
133
- 'polarity': float (-1 to 1),
134
- 'subjectivity': float (0 to 1),
135
- 'confidence': float (0 to 1)
136
- }
137
- """
138
- # Normalize and tokenize text
139
- text = self.normalizer.normalize(text)
140
- words = self.word_tokenizer.tokenize(text)
141
-
142
- positive_score = 0
143
- negative_score = 0
144
- word_count = len(words)
145
-
146
- for i, word in enumerate(words):
147
- word = word.lower()
148
- multiplier = self._get_intensity_multiplier(words, i)
149
- is_negated = self._is_negated(words, i)
150
-
151
- if word in self.positive_words:
152
- score = 1.0 * multiplier
153
- positive_score += -score if is_negated else score
154
- elif word in self.negative_words:
155
- score = 1.0 * multiplier
156
- negative_score += -score if is_negated else score
157
-
158
- # Calculate metrics
159
- total_score = positive_score + negative_score
160
- total_magnitude = abs(positive_score) + abs(negative_score)
161
-
162
- if word_count == 0:
163
- return {'polarity': 0.0, 'subjectivity': 0.0, 'confidence': 0.0}
164
-
165
- polarity = total_score / (word_count or 1) # Normalize to [-1, 1]
166
- subjectivity = total_magnitude / (word_count or 1) # Normalize to [0, 1]
167
- confidence = min(1.0, total_magnitude / (word_count / 2)) # Confidence based on magnitude
168
-
169
- return {
170
- 'polarity': max(-1.0, min(1.0, polarity)),
171
- 'subjectivity': min(1.0, subjectivity),
172
- 'confidence': confidence
173
- }
174
-
175
- def analyze_emotions(self, text: str) -> List[Tuple[str, float]]:
176
- """
177
- Analyze emotions in text.
178
-
179
- Returns:
180
- List of (emotion, score) tuples, sorted by score
181
- """
182
- # Normalize and tokenize text
183
- text = self.normalizer.normalize(text)
184
- words = self.word_tokenizer.tokenize(text)
185
-
186
- emotion_scores = {emotion: 0.0 for emotion in self.emotion_words}
187
-
188
- for i, word in enumerate(words):
189
- word = word.lower()
190
- multiplier = self._get_intensity_multiplier(words, i)
191
- is_negated = self._is_negated(words, i)
192
-
193
- for emotion, emotion_set in self.emotion_words.items():
194
- if word in emotion_set:
195
- score = 1.0 * multiplier
196
- emotion_scores[emotion] += -score if is_negated else score
197
-
198
- # Normalize scores
199
- max_score = max(abs(score) for score in emotion_scores.values()) or 1
200
- normalized_scores = [
201
- (emotion, score/max_score)
202
- for emotion, score in emotion_scores.items()
203
- ]
204
-
205
- # Sort by score
206
- return sorted(normalized_scores, key=lambda x: x[1], reverse=True)
webstoken/stemmer.py DELETED
@@ -1,73 +0,0 @@
1
- """
2
- Word stemming utilities.
3
- """
4
-
5
- from typing import Set
6
-
7
-
8
- class Stemmer:
9
- """Simple rule-based stemmer implementing Porter-like rules."""
10
-
11
- def __init__(self):
12
- self.vowels: Set[str] = {'a', 'e', 'i', 'o', 'u', 'y'}
13
- self.doubles: Set[str] = {'bb', 'dd', 'ff', 'gg', 'mm', 'nn', 'pp', 'rr', 'tt'}
14
-
15
- def is_vowel(self, char: str, prev_char: str = None) -> bool:
16
- """Check if a character is a vowel, considering 'y' special cases."""
17
- return char in self.vowels or (char == 'y' and prev_char and prev_char not in self.vowels)
18
-
19
- def count_syllables(self, word: str) -> int:
20
- """Count syllables in a word based on vowel sequences."""
21
- count = 0
22
- prev_char = None
23
- for i, char in enumerate(word.lower()):
24
- if self.is_vowel(char, prev_char) and (i == 0 or not self.is_vowel(prev_char, word[i-2] if i > 1 else None)):
25
- count += 1
26
- prev_char = char
27
- return count or 1
28
-
29
- def stem(self, word: str) -> str:
30
- """Apply stemming rules to reduce word to its root form."""
31
- if len(word) <= 3:
32
- return word
33
-
34
- word = word.lower()
35
-
36
- # Step 1: Handle plurals and past participles
37
- if word.endswith('sses'):
38
- word = word[:-2]
39
- elif word.endswith('ies'):
40
- word = word[:-2]
41
- elif word.endswith('ss'):
42
- pass
43
- elif word.endswith('s') and len(word) > 4:
44
- word = word[:-1]
45
-
46
- # Step 2: Handle -ed and -ing
47
- if word.endswith('ed') and self.count_syllables(word[:-2]) > 1:
48
- word = word[:-2]
49
- elif word.endswith('ing') and self.count_syllables(word[:-3]) > 1:
50
- word = word[:-3]
51
-
52
- # Step 3: Handle miscellaneous endings
53
- if len(word) > 5:
54
- if word.endswith('ement'):
55
- word = word[:-5]
56
- elif word.endswith('ment'):
57
- word = word[:-4]
58
- elif word.endswith('ent'):
59
- word = word[:-3]
60
-
61
- # Step 4: Handle -ity endings
62
- if word.endswith('ity') and len(word) > 6:
63
- word = word[:-3]
64
- if word.endswith('abil'):
65
- word = word[:-4] + 'able'
66
- elif word.endswith('ic'):
67
- word = word[:-2]
68
-
69
- # Final step: Remove double consonants at the end
70
- if len(word) > 2 and word[-2:] in self.doubles:
71
- word = word[:-1]
72
-
73
- return word
webstoken/tagger.py DELETED
@@ -1,60 +0,0 @@
1
- """
2
- Part-of-Speech tagging utilities.
3
- """
4
-
5
- from typing import List, Set, Tuple
6
-
7
-
8
- class POSTagger:
9
- """Simple rule-based Part-of-Speech tagger."""
10
-
11
- def __init__(self):
12
- # Basic rules for POS tagging
13
- self.noun_suffixes: Set[str] = {'ness', 'ment', 'ship', 'dom', 'hood', 'er', 'or', 'ist'}
14
- self.verb_suffixes: Set[str] = {'ize', 'ate', 'ify', 'ing', 'ed'}
15
- self.adj_suffixes: Set[str] = {'able', 'ible', 'al', 'ful', 'ous', 'ive', 'less'}
16
- self.adv_suffixes: Set[str] = {'ly'}
17
-
18
- # Common words by POS
19
- self.determiners: Set[str] = {'the', 'a', 'an', 'this', 'that', 'these', 'those'}
20
- self.prepositions: Set[str] = {'in', 'on', 'at', 'by', 'with', 'from', 'to', 'for'}
21
- self.pronouns: Set[str] = {'i', 'you', 'he', 'she', 'it', 'we', 'they', 'me', 'him', 'her'}
22
-
23
- def tag(self, tokens: List[str]) -> List[Tuple[str, str]]:
24
- """Assign POS tags to tokens based on rules."""
25
- tagged = []
26
- prev_tag = None
27
-
28
- for i, token in enumerate(tokens):
29
- word = token.lower()
30
-
31
- # Check special cases first
32
- if word in self.determiners:
33
- tag = 'DET'
34
- elif word in self.prepositions:
35
- tag = 'PREP'
36
- elif word in self.pronouns:
37
- tag = 'PRON'
38
- # Check suffixes
39
- elif any(word.endswith(suffix) for suffix in self.noun_suffixes):
40
- tag = 'NOUN'
41
- elif any(word.endswith(suffix) for suffix in self.verb_suffixes):
42
- tag = 'VERB'
43
- elif any(word.endswith(suffix) for suffix in self.adj_suffixes):
44
- tag = 'ADJ'
45
- elif any(word.endswith(suffix) for suffix in self.adv_suffixes):
46
- tag = 'ADV'
47
- # Default cases
48
- elif word[0].isupper() and i > 0:
49
- tag = 'PROPN' # Proper noun
50
- elif word.isdigit():
51
- tag = 'NUM'
52
- elif not word.isalnum():
53
- tag = 'PUNCT'
54
- else:
55
- tag = 'NOUN' # Default to noun
56
-
57
- tagged.append((token, tag))
58
- prev_tag = tag
59
-
60
- return tagged