-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhumanize.py
More file actions
executable file
·93 lines (75 loc) · 2.47 KB
/
humanize.py
File metadata and controls
executable file
·93 lines (75 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
"""Remove AI writing tells from text.
Common giveaways:
- Em dashes (—) → regular dash (-)
- "Delve/dive into" → "look at"
- "It's worth noting" → delete
- "Importantly" → delete
- Perfect parallel structure → roughen it up
- Overly clean lists → add variance
"""
import re
import sys
AI_TELLS = {
# Em dashes
r'—': '-',
# Overused phrases
r'\bdelve into\b': 'look at',
r'\bdive into\b': 'look at',
r'\bunpack\b': 'examine',
r"It's worth noting that\s*": '',
r"Let's be clear:\s*": '',
r"Let's be honest:\s*": '',
r'\bImportantly,\s*': '',
r'\bCrucially,\s*': '',
r'\bFundamentally,\s*': '',
# Sentence starters
r'\bThis is where\b': 'Here',
r'\bThat being said,\s*': '',
r'\bWith that in mind,\s*': '',
# Hedging
r'\bquite\b': '',
r'\bsomewhat\b': '',
r'\brather\b': '',
r'\ba bit\b': '',
}
def humanize(text):
"""Apply all transformations."""
result = text
for pattern, replacement in AI_TELLS.items():
result = re.sub(pattern, replacement, result, flags=re.IGNORECASE)
# Clean up double spaces
result = re.sub(r' +', ' ', result)
# Clean up space before punctuation
result = re.sub(r' +([.,!?])', r'\1', result)
return result.strip()
def detect_tells(text):
"""Find AI tells in text."""
tells = []
if '—' in text:
tells.append(f"Em dash found: {text.count('—')} instances")
for pattern in AI_TELLS.keys():
if re.search(pattern, text, re.IGNORECASE):
tells.append(f"AI phrase: {pattern}")
# Check for perfect parallel structure (3+ sentences starting with same word)
sentences = [s.strip() for s in re.split(r'[.!?]', text) if s.strip()]
if len(sentences) >= 3:
first_words = [s.split()[0] if s.split() else '' for s in sentences]
for word in set(first_words):
if first_words.count(word) >= 3:
tells.append(f"Parallel structure: {first_words.count(word)} sentences start with '{word}'")
return tells
if __name__ == '__main__':
if len(sys.argv) > 1:
text = ' '.join(sys.argv[1:])
else:
text = sys.stdin.read()
print("=== AI TELLS DETECTED ===")
tells = detect_tells(text)
if tells:
for tell in tells:
print(f" • {tell}")
else:
print(" None found")
print("\n=== HUMANIZED VERSION ===")
print(humanize(text))