folder-classifier 0.3.6__py3-none-any.whl → 0.3.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.
- folder_classifier/classifier.py +66 -64
- {folder_classifier-0.3.6.dist-info → folder_classifier-0.3.8.dist-info}/METADATA +1 -1
- {folder_classifier-0.3.6.dist-info → folder_classifier-0.3.8.dist-info}/RECORD +5 -5
- {folder_classifier-0.3.6.dist-info → folder_classifier-0.3.8.dist-info}/WHEEL +0 -0
- {folder_classifier-0.3.6.dist-info → folder_classifier-0.3.8.dist-info}/top_level.txt +0 -0
folder_classifier/classifier.py
CHANGED
@@ -7,71 +7,70 @@ from ray import serve
|
|
7
7
|
from folder_classifier.dto import FolderClassificationRequest, FolderClassification
|
8
8
|
from folder_classifier.util import build_folder, render_tree
|
9
9
|
|
10
|
-
SYSTEM_PROMPT = """
|
11
|
-
You are a strict text classifier.
|
12
|
-
|
13
|
-
- "
|
14
|
-
|
15
|
-
- Do not include any double-quote (") characters inside the value of "reasoning"; use single quotes ' instead.
|
16
|
-
- No backticks, no code fences, no extra text. Return one JSON object only.
|
17
|
-
No step-by-step thinking. No extra keys. If unsure, choose "other".
|
10
|
+
SYSTEM_PROMPT = r"""
|
11
|
+
You are a strict text classifier. Provide a single JSON object with exactly two keys: "category" and "reasoning".
|
12
|
+
- "category": either "matter" or "other" (lowercase).
|
13
|
+
- "reasoning": 1–2 short explanation referencing the key rule(s) that decided it.
|
14
|
+
No markdown (no backticks or code blocks) or any extra text outside the JSON. No chain-of-thought explanations or extra keys. If uncertain, choose "other".
|
18
15
|
""".strip()
|
19
16
|
|
20
|
-
USER_PROMPT_TEMPLATE = """
|
21
|
-
Classify the
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
17
|
+
USER_PROMPT_TEMPLATE = r"""
|
18
|
+
Task: Classify the root folder as 'matter' or 'other'.
|
19
|
+
|
20
|
+
Decision rules (apply in order):
|
21
|
+
1) If there are no files with extension anywhere in the tree , classify as 'other'.
|
22
|
+
2) If the root folder appears to be a container of multiple matters , classify as 'other'.
|
23
|
+
3) If the root folder is or ends with a common subfolder name or descriptor found inside legal matters (e.g.,"Email", "Summons" "Emails", "Documents", "Correspondence", "Drafts", "Pleadings", "Court Documents", "Billing", or similar descriptive folder types), classify as 'other' even if it contains legal documents.
|
24
|
+
4) If the root folder is a subfolder of a matter, classify as other
|
25
|
+
5) If the root folder name matches any Matter Folder Naming Pattern and there is at least one file with an extension anywhere in the tree (including subfolders), and there is at least one file, subfolder, or filename that directly and unambiguously references a legal, client-matter, or professional context—for example, a legal document type, an initial or core legal document, clear legal terminology, a jurisdiction/court reference, the name of a law firm or legal/financial professional, or an activity specific to legal work—classify as 'matter'.
|
26
|
+
Do not classify as 'matter' if the folder only contains general business documents (e.g., invoices, estimates, generic correspondence) and there are no strong indicators of legal, client, or matter-related content as defined above
|
27
|
+
6) If the root folder name very compellingly looks like a matter folder e.g (11206 - AcmeX Pty v Acme Corp), classify as 'matter' even if the documents are not initial/core/legal documents.
|
28
|
+
7) If none of the above apply, classify as 'other'.
|
29
|
+
|
30
|
+
Matter Folder Naming Patterns (case-insensitive; separators like space, hyphen, underscore are fine):
|
31
|
+
• Matter number alone or combined with a client/surname/company (e.g., "12345", "12345 Smith", "Smith - Contract Dispute").
|
32
|
+
• Client name/surname/company/business name, optionally with matter type or client reference (e.g., "Brown – Lease Review", "Jones Family – Estate").
|
33
|
+
• Common file-number prefixes/suffixes (e.g., "MAT-1234", "CLT001", "2025-0001", "ACME_2024_Lease").
|
34
|
+
• Suggested regex-style hints (not strict requirements):
|
35
|
+
- Numeric ID: ^\d{4,}$
|
36
|
+
- Prefixed ID: ^(MAT|CLT|FILE|CASE|REF)[-_]?\d{3,}
|
37
|
+
- Name + type: ^[A-Za-z].*(Lease|Contract|Estate|Dispute|Sale|Acquisition|Conveyance|Family|Probate|Litigation).*
|
38
|
+
|
39
|
+
Initial or Core Documents (early-stage client docs):
|
40
|
+
• File Cover Sheet
|
41
|
+
• Cost Agreement / Costs Disclosure
|
42
|
+
• Retainer Instructions / Engagement Letter
|
43
|
+
• Onboarding Questionnaire / Client Intake Form
|
44
|
+
|
45
|
+
Legal Document Types (non-exhaustive):
|
46
|
+
• Contract, Deed, Agreement, Will
|
47
|
+
• Affidavit, Statement
|
48
|
+
• Brief to Counsel, Advice
|
49
|
+
• Court Forms, Pleadings, Subpoena, Orders, Judgment, Undertaking
|
50
|
+
|
51
|
+
Subfolder Indicators (often—but not always—present in matters):
|
52
|
+
• Correspondence / Emails
|
53
|
+
• File Notes / Attendance Notes
|
54
|
+
• Searches / Certificates
|
55
|
+
• Court Documents / Evidence / Disclosure / Discovery
|
56
|
+
• Drafts / Final / Signed / Executed
|
57
|
+
• Billing / Invoices / Time Records
|
58
|
+
|
59
|
+
File Naming Patterns (helpful signals):
|
60
|
+
• Dates in YYYYMMDD or DDMMYYYY.
|
61
|
+
• Legal terminology (e.g., "Letter to other side", "Draft_Affidavit_v3").
|
62
|
+
• Versioning (v1, v2, Final, Executed, Signed).
|
63
|
+
• Jurisdiction or court references (e.g., NSWSC, VCAT, Family Court, FCFCOA).
|
64
|
+
|
65
|
+
Definitions/assumptions:
|
66
|
+
• "Document" = a file (e.g., .pdf, .docx, .rtf, .txt, .xlsx, .msg/.eml). Folders are not documents.
|
67
|
+
• Treat "templates" or "precedents" as weak signals unless clearly client/matter-specific.
|
68
|
+
• Evaluate only the content shown in the tree—do not infer from outside knowledge.
|
69
|
+
|
70
|
+
Output format (JSON only, no extra text):
|
71
|
+
{"category": "<matter|other>", "reasoning": "<1–2 short explanation referencing the key rule(s) that decided it>"}
|
72
|
+
ROOT FOLDER:
|
73
|
+
{root_folder}
|
75
74
|
FOLDER TREE:
|
76
75
|
{folder_tree}
|
77
76
|
""".strip()
|
@@ -106,12 +105,15 @@ class FolderClassifier:
|
|
106
105
|
def _to_chat_completion_request(self, request: FolderClassificationRequest) -> Dict[str, Any]:
|
107
106
|
input_paths = request.items
|
108
107
|
folder = build_folder(input_paths)
|
108
|
+
root_folder = folder.name
|
109
109
|
folder_tree = render_tree(folder)
|
110
110
|
chat_completion_request = {
|
111
111
|
"model": self.model,
|
112
112
|
"messages": [
|
113
113
|
{"role": "system", "content": SYSTEM_PROMPT},
|
114
|
-
{"role": "user", "content": USER_PROMPT_TEMPLATE.
|
114
|
+
{"role": "user", "content": USER_PROMPT_TEMPLATE.
|
115
|
+
replace("{root_folder}", root_folder).
|
116
|
+
replace("{folder_tree}", folder_tree)}
|
115
117
|
],
|
116
118
|
"max_tokens": 1024,
|
117
119
|
"temperature": 0.7,
|
@@ -1,10 +1,10 @@
|
|
1
1
|
folder_classifier/__init__.py,sha256=k0YWZyUNe7myJiKeX0OaXtJ30_3EGE-vsZiAUbqa-3E,46
|
2
2
|
folder_classifier/app.py,sha256=5eaniDWZFBvyI9UN4vOCc6TQwgyptAUVhRVgfrjp2F4,1259
|
3
|
-
folder_classifier/classifier.py,sha256=
|
3
|
+
folder_classifier/classifier.py,sha256=tTTu3B-vEtWaFeRMCKCpEcQJ1mo3GB5aDpi46HIB7j0,7223
|
4
4
|
folder_classifier/deploy.py,sha256=06UAxz40IaP28e_RRohJoFwPUrWTaMquGbDylI-oHWA,424
|
5
5
|
folder_classifier/dto.py,sha256=KRHEfXKlsIYkBySwHOlo4k5Z4J_F3eR3PeEdUAwj8lI,819
|
6
6
|
folder_classifier/util.py,sha256=-Ptxkba5UzmhLrqoiiKZS3G56_cuAMkWlTyHcqdJkg0,3160
|
7
|
-
folder_classifier-0.3.
|
8
|
-
folder_classifier-0.3.
|
9
|
-
folder_classifier-0.3.
|
10
|
-
folder_classifier-0.3.
|
7
|
+
folder_classifier-0.3.8.dist-info/METADATA,sha256=VseLFnkWW-q2uO_F22MRJhuQcjkmxyv0qqi4MOmsSYc,546
|
8
|
+
folder_classifier-0.3.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
folder_classifier-0.3.8.dist-info/top_level.txt,sha256=36ugc9pEbNQ-mnzz4Ot2WVjY3t_LzAN6XOCjDFP4p4k,18
|
10
|
+
folder_classifier-0.3.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|