acuity-framework 2.0.2__tar.gz → 3.0.0__tar.gz

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.
Files changed (40) hide show
  1. {acuity_framework-2.0.2/acuity_framework.egg-info → acuity_framework-3.0.0}/PKG-INFO +331 -255
  2. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/README.md +79 -3
  3. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/__init__.py +1 -1
  4. acuity_framework-3.0.0/acuity/extraction/interfaces.py +51 -0
  5. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/extraction/pipeline.py +72 -5
  6. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/extraction/rules.py +5 -5
  7. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/recommendation/engine.py +23 -4
  8. acuity_framework-3.0.0/acuity/recommendation/interfaces.py +58 -0
  9. acuity_framework-3.0.0/acuity/scraper/interfaces.py +58 -0
  10. {acuity_framework-2.0.2 → acuity_framework-3.0.0/acuity_framework.egg-info}/PKG-INFO +331 -255
  11. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity_framework.egg-info/SOURCES.txt +3 -0
  12. acuity_framework-3.0.0/acuity_framework.egg-info/top_level.txt +1 -0
  13. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/pyproject.toml +1 -1
  14. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/setup.cfg +4 -4
  15. acuity_framework-3.0.0/setup.py +100 -0
  16. acuity_framework-2.0.2/acuity_framework.egg-info/top_level.txt +0 -2
  17. acuity_framework-2.0.2/setup.py +0 -116
  18. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/LICENSE +0 -0
  19. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/config.py +0 -0
  20. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/extraction/__init__.py +0 -0
  21. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/extraction/ner_crf.py +0 -0
  22. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/extraction/ner_transformer.py +0 -0
  23. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/extraction/postprocessing.py +0 -0
  24. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/extraction/preprocessing.py +0 -0
  25. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/recommendation/__init__.py +0 -0
  26. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/recommendation/proximity.py +0 -0
  27. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/recommendation/ranker.py +0 -0
  28. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/recommendation/similarity.py +0 -0
  29. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/recommendation/vectorizer.py +0 -0
  30. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/scraper/__init__.py +0 -0
  31. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/scraper/scraper.py +0 -0
  32. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/scraper/utils.py +0 -0
  33. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/utils.py +0 -0
  34. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/verification/__init__.py +0 -0
  35. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity/verification/bplo.py +0 -0
  36. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity_framework.egg-info/dependency_links.txt +0 -0
  37. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/acuity_framework.egg-info/requires.txt +0 -0
  38. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/tests/test_extraction.py +0 -0
  39. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/tests/test_recommendation.py +0 -0
  40. {acuity_framework-2.0.2 → acuity_framework-3.0.0}/tests/test_verification.py +0 -0
@@ -1,255 +1,331 @@
1
- Metadata-Version: 2.4
2
- Name: acuity-framework
3
- Version: 2.0.2
4
- Summary: ACUITY — A machine learning framework for extracting, verifying, and recommending local micro-enterprise profiles from unstructured community posts.
5
- Author: ACUITY Research Team
6
- License: MIT
7
- Project-URL: Repository, https://github.com/acuity-framework/acuity-framework
8
- Project-URL: Documentation, https://github.com/acuity-framework/acuity-framework#readme
9
- Keywords: nlp,ner,recommendation-engine,tfidf,cosine-similarity,business-extraction,community-posts,micro-enterprise
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Intended Audience :: Science/Research
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
- Classifier: Topic :: Text Processing :: Linguistic
20
- Requires-Python: >=3.10
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Provides-Extra: nlp
24
- Requires-Dist: nltk>=3.8.1; extra == "nlp"
25
- Provides-Extra: transformers
26
- Requires-Dist: transformers>=4.35.0; extra == "transformers"
27
- Requires-Dist: torch>=2.1.0; extra == "transformers"
28
- Requires-Dist: nltk>=3.8.1; extra == "transformers"
29
- Provides-Extra: scraper
30
- Requires-Dist: undetected-chromedriver>=3.5.0; extra == "scraper"
31
- Requires-Dist: selenium>=4.15.0; extra == "scraper"
32
- Requires-Dist: python-dotenv>=1.0.0; extra == "scraper"
33
- Provides-Extra: all
34
- Requires-Dist: nltk>=3.8.1; extra == "all"
35
- Requires-Dist: transformers>=4.35.0; extra == "all"
36
- Requires-Dist: torch>=2.1.0; extra == "all"
37
- Requires-Dist: undetected-chromedriver>=3.5.0; extra == "all"
38
- Requires-Dist: selenium>=4.15.0; extra == "all"
39
- Requires-Dist: python-dotenv>=1.0.0; extra == "all"
40
- Provides-Extra: dev
41
- Requires-Dist: pytest>=7.4.0; extra == "dev"
42
- Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
43
- Dynamic: license-file
44
-
45
- # ACUITY Framework
46
-
47
- **A**utomated **C**ommunity **U**nstructured **I**nformation to **T**argeted visibilit**Y**
48
-
49
- A Python machine learning framework for extracting, verifying, and recommending local micro-enterprise profiles from unstructured community posts (e.g., Facebook groups, forums).
50
-
51
- ---
52
-
53
- ## 🚀 Installation
54
-
55
- ```bash
56
- # Core framework (no heavy dependencies)
57
- pip install acuity-framework
58
-
59
- # With NLP support (nltk for CRF-based NER)
60
- pip install acuity-framework[nlp]
61
-
62
- # With Transformer NER (requires PyTorch)
63
- pip install acuity-framework[transformers]
64
-
65
- # With Facebook scraper
66
- pip install acuity-framework[scraper]
67
-
68
- # Everything
69
- pip install acuity-framework[all]
70
- ```
71
-
72
- ### Local Development Install
73
-
74
- ```bash
75
- git clone https://github.com/acuity-framework/acuity-framework.git
76
- cd acuity-framework
77
- pip install -e ".[dev]"
78
- ```
79
-
80
- ---
81
-
82
- ## 📦 Modules
83
-
84
- | Module | Description |
85
- |--------|-------------|
86
- | `acuity.extraction` | NLP pipeline: preprocessing → NER → rule-based extraction → profile construction |
87
- | `acuity.recommendation` | TF-IDF + cosine similarity + Haversine proximity ranking |
88
- | `acuity.verification` | Business legitimacy verification via fuzzy matching (Levenshtein) |
89
- | `acuity.scraper` | Facebook community group post scraper (optional) |
90
-
91
- ---
92
-
93
- ## 🔧 Quick Start
94
-
95
- ### 1. Extract Business Profiles from Text
96
-
97
- ```python
98
- from acuity.extraction import ExtractionPipeline
99
-
100
- pipeline = ExtractionPipeline()
101
- profiles = pipeline.extract_from_texts([
102
- "Mang Juan's Bakery sa Mamatid, open 8am-5pm, 0917-123-4567, pandesal ₱5",
103
- "JC Auto Repair, vulcanizing, Brgy Banay-Banay, 0918-987-6543",
104
- ])
105
-
106
- for p in profiles:
107
- print(f"{p['business_name']}: {p['phones']}, {p['hours']}")
108
- ```
109
-
110
- ### 2. Verify Against a Government Registry
111
-
112
- ```python
113
- from acuity.verification import BPLOVerifier
114
-
115
- verifier = BPLOVerifier()
116
- verifier.load_registry_from_list([
117
- {"name": "Juan's Bakeshop", "address": "Mamatid"},
118
- {"name": "JC Automotive Repair", "address": "Banay-Banay"},
119
- ])
120
-
121
- result = verifier.verify("Mang Juan's Bakery")
122
- print(f"Status: {result['status']}, Score: {result['score']}")
123
- # Output: Status: Pending Verification, Score: 0.65
124
- ```
125
-
126
- ### 3. Recommend Businesses
127
-
128
- ```python
129
- from acuity.recommendation import RecommendationEngine
130
-
131
- engine = RecommendationEngine()
132
- engine.set_profiles([
133
- {"name": "Juan's Bakery", "description": "Fresh bread daily", "latitude": 14.27, "longitude": 121.12},
134
- {"name": "Auto Repair", "description": "Vulcanizing and oil change", "latitude": 14.26, "longitude": 121.11},
135
- ])
136
-
137
- results = engine.recommend("bakery bread", user_lat=14.27, user_lon=121.12)
138
- for r in results:
139
- print(f"{r['name']}: score={r['final_score']}, dist={r['distance_km']}km")
140
- ```
141
-
142
- ---
143
-
144
- ## ⚙️ Configuration
145
-
146
- All settings are controlled via the `AcuityConfig` dataclass:
147
-
148
- ```python
149
- from acuity.config import AcuityConfig
150
-
151
- config = AcuityConfig(
152
- # NER settings
153
- ner_backend="crf", # "crf" or "transformer"
154
- ner_model_path="./models/crf.pkl", # Path to your trained model
155
-
156
- # Recommendation weights
157
- relevance_weight=0.6,
158
- proximity_weight=0.4,
159
- default_top_k=10,
160
-
161
- # Verification thresholds
162
- fuzzy_match_threshold_verified=0.8,
163
- fuzzy_match_threshold_pending=0.6,
164
- )
165
- ```
166
-
167
- ---
168
-
169
- ## 🌐 Integrating with Your Web Application
170
-
171
- ACUITY is framework-agnostic. Here's how to use it with Flask:
172
-
173
- ```python
174
- from flask import Flask, request, jsonify
175
- from acuity.recommendation import RecommendationEngine
176
-
177
- app = Flask(__name__)
178
- engine = RecommendationEngine()
179
-
180
- @app.route("/api/recommend")
181
- def recommend():
182
- query = request.args.get("q", "")
183
- results = engine.recommend(query)
184
- return jsonify(results)
185
- ```
186
-
187
- See [`examples/flask_integration.py`](examples/flask_integration.py) for a complete working example.
188
-
189
- ---
190
-
191
- ## 🧪 Running Tests
192
-
193
- ```bash
194
- pip install -e ".[dev]"
195
- pytest tests/ -v
196
- ```
197
-
198
- ---
199
-
200
- ## 📁 Project Structure
201
-
202
- ```
203
- acuity-framework/
204
- ├── pyproject.toml # Package configuration
205
- ├── README.md
206
- ├── LICENSE
207
- ├── acuity/
208
- │ ├── __init__.py # Public API
209
- │ ├── config.py # AcuityConfig dataclass
210
- │ ├── utils.py # Levenshtein similarity utilities
211
- │ ├── extraction/ # NLP extraction pipeline
212
- │ │ ├── pipeline.py # ExtractionPipeline class
213
- │ │ ├── preprocessing.py
214
- │ │ ├── ner_crf.py
215
- │ │ ├── ner_transformer.py
216
- │ │ ├── rules.py
217
- │ │ └── postprocessing.py
218
- │ ├── recommendation/ # Recommendation engine
219
- │ │ ├── engine.py # RecommendationEngine class
220
- │ │ ├── vectorizer.py # TF-IDF vectorizer
221
- │ │ ├── similarity.py # Cosine similarity
222
- │ │ ├── proximity.py # Haversine distance
223
- │ │ └── ranker.py # Combined ranking
224
- │ ├── verification/ # Business verification
225
- │ │ └── bplo.py # BPLOVerifier class
226
- │ └── scraper/ # Facebook scraper (optional)
227
- │ ├── scraper.py # FacebookScraper class
228
- │ └── utils.py
229
- ├── examples/
230
- │ ├── basic_extraction.py
231
- │ ├── basic_recommendation.py
232
- │ └── flask_integration.py
233
- └── tests/
234
- ├── test_extraction.py
235
- ├── test_recommendation.py
236
- └── test_verification.py
237
- ```
238
-
239
- ---
240
-
241
- ## 📄 License
242
-
243
- MIT License see [LICENSE](LICENSE) for details.
244
-
245
- ---
246
-
247
- ## 🎓 Academic Reference
248
-
249
- This framework was developed as part of an academic thesis at the College of Computing Studies. The core algorithms implement:
250
-
251
- - **TF-IDF Vectorization** with log-normalised term frequency and inverse document frequency
252
- - **Cosine Similarity** for textual relevance scoring
253
- - **Haversine Formula** for geographic proximity computation
254
- - **CRF (Conditional Random Field)** for Named Entity Recognition with BIO tagging
255
- - **Levenshtein Distance** for fuzzy string matching in business verification
1
+ Metadata-Version: 2.4
2
+ Name: acuity-framework
3
+ Version: 3.0.0
4
+ Summary: ACUITY — A machine learning framework for extracting, verifying, and recommending local micro-enterprise profiles from unstructured community posts.
5
+ Author: ACUITY Research Team
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/acuity-framework/acuity-framework
8
+ Project-URL: Documentation, https://github.com/acuity-framework/acuity-framework#readme
9
+ Keywords: nlp,ner,recommendation-engine,tfidf,cosine-similarity,business-extraction,community-posts,micro-enterprise
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Text Processing :: Linguistic
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Provides-Extra: nlp
24
+ Requires-Dist: nltk>=3.8.1; extra == "nlp"
25
+ Provides-Extra: transformers
26
+ Requires-Dist: transformers>=4.35.0; extra == "transformers"
27
+ Requires-Dist: torch>=2.1.0; extra == "transformers"
28
+ Requires-Dist: nltk>=3.8.1; extra == "transformers"
29
+ Provides-Extra: scraper
30
+ Requires-Dist: undetected-chromedriver>=3.5.0; extra == "scraper"
31
+ Requires-Dist: selenium>=4.15.0; extra == "scraper"
32
+ Requires-Dist: python-dotenv>=1.0.0; extra == "scraper"
33
+ Provides-Extra: all
34
+ Requires-Dist: nltk>=3.8.1; extra == "all"
35
+ Requires-Dist: transformers>=4.35.0; extra == "all"
36
+ Requires-Dist: torch>=2.1.0; extra == "all"
37
+ Requires-Dist: undetected-chromedriver>=3.5.0; extra == "all"
38
+ Requires-Dist: selenium>=4.15.0; extra == "all"
39
+ Requires-Dist: python-dotenv>=1.0.0; extra == "all"
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
42
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # ACUITY Framework
46
+
47
+ **A**utomated **C**ommunity **U**nstructured **I**nformation to **T**argeted visibilit**Y**
48
+
49
+ A Python machine learning framework for extracting, verifying, and recommending local micro-enterprise profiles from unstructured community posts (e.g., Facebook groups, forums).
50
+
51
+ ---
52
+
53
+ ## 🚀 Installation
54
+
55
+ ```bash
56
+ # Core framework (no heavy dependencies)
57
+ pip install acuity-framework
58
+
59
+ # With NLP support (nltk for CRF-based NER)
60
+ pip install acuity-framework[nlp]
61
+
62
+ # With Transformer NER (requires PyTorch)
63
+ pip install acuity-framework[transformers]
64
+
65
+ # With Facebook scraper
66
+ pip install acuity-framework[scraper]
67
+
68
+ # Everything
69
+ pip install acuity-framework[all]
70
+ ```
71
+
72
+ ### Local Development Install
73
+
74
+ ```bash
75
+ git clone https://github.com/acuity-framework/acuity-framework.git
76
+ cd acuity-framework
77
+ pip install -e ".[dev]"
78
+ ```
79
+
80
+ ---
81
+
82
+ ## 📦 Modules
83
+
84
+ | Module | Description |
85
+ |--------|-------------|
86
+ | `acuity.extraction` | NLP pipeline: preprocessing → NER → rule-based extraction → profile construction |
87
+ | `acuity.recommendation` | TF-IDF + cosine similarity + Haversine proximity ranking |
88
+ | `acuity.verification` | Business legitimacy verification via fuzzy matching (Levenshtein) |
89
+ | `acuity.scraper` | Facebook community group post scraper (optional) |
90
+
91
+ ---
92
+
93
+ ## 🔧 Quick Start
94
+
95
+ ### 1. Extract Business Profiles from Text
96
+
97
+ ```python
98
+ from acuity.extraction import ExtractionPipeline
99
+
100
+ pipeline = ExtractionPipeline()
101
+ profiles = pipeline.extract_from_texts([
102
+ "Mang Juan's Bakery sa Mamatid, open 8am-5pm, 0917-123-4567, pandesal ₱5",
103
+ "JC Auto Repair, vulcanizing, Brgy Banay-Banay, 0918-987-6543",
104
+ ])
105
+
106
+ for p in profiles:
107
+ print(f"{p['business_name']}: {p['phones']}, {p['hours']}")
108
+ ```
109
+
110
+ ### 2. Verify Against a Government Registry
111
+
112
+ ```python
113
+ from acuity.verification import BPLOVerifier
114
+
115
+ verifier = BPLOVerifier()
116
+ verifier.load_registry_from_list([
117
+ {"name": "Juan's Bakeshop", "address": "Mamatid"},
118
+ {"name": "JC Automotive Repair", "address": "Banay-Banay"},
119
+ ])
120
+
121
+ result = verifier.verify("Mang Juan's Bakery")
122
+ print(f"Status: {result['status']}, Score: {result['score']}")
123
+ # Output: Status: Pending Verification, Score: 0.65
124
+ ```
125
+
126
+ ### 3. Recommend Businesses
127
+
128
+ ```python
129
+ from acuity.recommendation import RecommendationEngine
130
+
131
+ engine = RecommendationEngine()
132
+ engine.set_profiles([
133
+ {"name": "Juan's Bakery", "description": "Fresh bread daily", "latitude": 14.27, "longitude": 121.12},
134
+ {"name": "Auto Repair", "description": "Vulcanizing and oil change", "latitude": 14.26, "longitude": 121.11},
135
+ ])
136
+
137
+ results = engine.recommend("bakery bread", user_lat=14.27, user_lon=121.12)
138
+ for r in results:
139
+ print(f"{r['name']}: score={r['final_score']}, dist={r['distance_km']}km")
140
+ ```
141
+
142
+ ---
143
+
144
+ ## 🔌 Extensibility (v3.0)
145
+
146
+ ACUITY v3.0 introduces **three pluggable extension points** via abstract base classes. You can inject custom implementations without modifying the framework's source code. All extension points are optional — existing code continues to work unchanged.
147
+
148
+ ### Custom NER Backend
149
+
150
+ Replace the built-in CRF/Transformer NER with your own implementation:
151
+
152
+ ```python
153
+ from acuity.extraction.interfaces import NERBackend
154
+ from acuity.extraction import ExtractionPipeline
155
+
156
+ class MyNERBackend(NERBackend):
157
+ def extract_entities(self, text: str) -> dict:
158
+ # Your custom entity extraction logic
159
+ return {
160
+ "business_name": ["Detected Name"],
161
+ "categories": ["food"],
162
+ "locations": ["Manila"],
163
+ }
164
+
165
+ # Inject it — existing config-based NER is used when ner_backend=None (default)
166
+ pipeline = ExtractionPipeline(ner_backend=MyNERBackend())
167
+ profiles = pipeline.extract_from_texts(["Sample post text"])
168
+ ```
169
+
170
+ ### Custom Data Source
171
+
172
+ Replace the Facebook scraper with any data source (CSV, database, API, etc.):
173
+
174
+ ```python
175
+ from acuity.scraper.interfaces import DataSource
176
+ from acuity.extraction import ExtractionPipeline
177
+
178
+ class MyDataSource(DataSource):
179
+ def fetch_posts(self, sources: list[str], max_posts: int = 500) -> list[dict]:
180
+ # Your custom data fetching logic
181
+ return [{"text": "Post content", "poster": "Author Name"}]
182
+
183
+ # Inject it and use extract_from_source() for fetch + extract in one call
184
+ pipeline = ExtractionPipeline(data_source=MyDataSource())
185
+ profiles = pipeline.extract_from_source(sources=["my_source_id"])
186
+ ```
187
+
188
+ ### Custom Ranking Strategy
189
+
190
+ Replace TF-IDF + cosine similarity with your own text-relevance scoring:
191
+
192
+ ```python
193
+ from acuity.recommendation.interfaces import RankingStrategy
194
+ from acuity.recommendation import RecommendationEngine
195
+
196
+ class MyRanking(RankingStrategy):
197
+ def compute_scores(self, profiles: list[dict], query: str) -> list[float]:
198
+ # Your custom relevance scoring logic
199
+ return [1.0 if query.lower() in str(p).lower() else 0.0 for p in profiles]
200
+
201
+ # Inject it — Haversine proximity is still used alongside (it's a fixed formula)
202
+ engine = RecommendationEngine(ranking_strategy=MyRanking())
203
+ engine.set_profiles(profiles)
204
+ results = engine.recommend("bakery")
205
+ ```
206
+
207
+ > **Note:** Haversine distance, the pipeline stage order (preprocess → NER → rules → postprocess), and Levenshtein fuzzy matching are intentionally **not** abstracted — they are fixed, correct algorithms with no legitimate variation.
208
+
209
+ See [`examples/demo_extensibility.py`](examples/demo_extensibility.py) for a complete end-to-end demo using all three extension points.
210
+
211
+ ---
212
+
213
+ ## ⚙️ Configuration
214
+
215
+ All settings are controlled via the `AcuityConfig` dataclass:
216
+
217
+ ```python
218
+ from acuity.config import AcuityConfig
219
+
220
+ config = AcuityConfig(
221
+ # NER settings
222
+ ner_backend="crf", # "crf" or "transformer"
223
+ ner_model_path="./models/crf.pkl", # Path to your trained model
224
+
225
+ # Recommendation weights
226
+ relevance_weight=0.6,
227
+ proximity_weight=0.4,
228
+ default_top_k=10,
229
+
230
+ # Verification thresholds
231
+ fuzzy_match_threshold_verified=0.8,
232
+ fuzzy_match_threshold_pending=0.6,
233
+ )
234
+ ```
235
+
236
+ ---
237
+
238
+ ## 🌐 Integrating with Your Web Application
239
+
240
+ ACUITY is framework-agnostic. Here's how to use it with Flask:
241
+
242
+ ```python
243
+ from flask import Flask, request, jsonify
244
+ from acuity.recommendation import RecommendationEngine
245
+
246
+ app = Flask(__name__)
247
+ engine = RecommendationEngine()
248
+
249
+ @app.route("/api/recommend")
250
+ def recommend():
251
+ query = request.args.get("q", "")
252
+ results = engine.recommend(query)
253
+ return jsonify(results)
254
+ ```
255
+
256
+ See [`examples/flask_integration.py`](examples/flask_integration.py) for a complete working example.
257
+
258
+ ---
259
+
260
+ ## 🧪 Running Tests
261
+
262
+ ```bash
263
+ pip install -e ".[dev]"
264
+ pytest tests/ -v
265
+ ```
266
+
267
+ ---
268
+
269
+ ## 📁 Project Structure
270
+
271
+ ```
272
+ acuity-framework/
273
+ ├── pyproject.toml # Package configuration
274
+ ├── README.md
275
+ ├── LICENSE
276
+ ├── acuity/
277
+ │ ├── __init__.py # Public API
278
+ │ ├── config.py # AcuityConfig dataclass
279
+ │ ├── utils.py # Levenshtein similarity utilities
280
+ │ ├── extraction/ # NLP extraction pipeline
281
+ │ │ ├── pipeline.py # ExtractionPipeline class
282
+ │ │ ├── interfaces.py # NERBackend ABC (extensibility)
283
+ │ │ ├── preprocessing.py
284
+ │ │ ├── ner_crf.py
285
+ │ │ ├── ner_transformer.py
286
+ │ │ ├── rules.py
287
+ │ │ └── postprocessing.py
288
+ │ ├── recommendation/ # Recommendation engine
289
+ │ │ ├── engine.py # RecommendationEngine class
290
+ │ │ ├── interfaces.py # RankingStrategy ABC (extensibility)
291
+ │ │ ├── vectorizer.py # TF-IDF vectorizer
292
+ │ │ ├── similarity.py # Cosine similarity
293
+ │ │ ├── proximity.py # Haversine distance (fixed, not abstracted)
294
+ │ │ └── ranker.py # Combined ranking
295
+ │ ├── verification/ # Business verification
296
+ │ │ └── bplo.py # BPLOVerifier class
297
+ │ └── scraper/ # Data collection (optional)
298
+ │ ├── scraper.py # FacebookScraper class
299
+ │ ├── interfaces.py # DataSource ABC (extensibility)
300
+ │ └── utils.py
301
+ ├── examples/
302
+ │ ├── basic_extraction.py
303
+ │ ├── basic_recommendation.py
304
+ │ ├── flask_integration.py
305
+ │ ├── custom_ner_backend.py # Example: KeywordNERBackend
306
+ │ ├── custom_data_source.py # Example: CSVDataSource
307
+ │ ├── custom_ranking_strategy.py # Example: KeywordMatchRanking
308
+ │ └── demo_extensibility.py # Combined end-to-end demo
309
+ └── tests/
310
+ ├── test_extraction.py
311
+ ├── test_recommendation.py
312
+ └── test_verification.py
313
+ ```
314
+
315
+ ---
316
+
317
+ ## 📄 License
318
+
319
+ MIT License — see [LICENSE](LICENSE) for details.
320
+
321
+ ---
322
+
323
+ ## 🎓 Academic Reference
324
+
325
+ This framework was developed as part of an academic thesis at the College of Computing Studies. The core algorithms implement:
326
+
327
+ - **TF-IDF Vectorization** with log-normalised term frequency and inverse document frequency
328
+ - **Cosine Similarity** for textual relevance scoring
329
+ - **Haversine Formula** for geographic proximity computation
330
+ - **CRF (Conditional Random Field)** for Named Entity Recognition with BIO tagging
331
+ - **Levenshtein Distance** for fuzzy string matching in business verification