-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_and_report.py
65 lines (53 loc) · 2.26 KB
/
process_and_report.py
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
import os
from lexdetect.analyze_text import analyze_text, output_metadata
from lexcognition_analytics.data_analysis import analyze_data
from lexprivacy.style_morphing import apply_style_morphing
from lexaudit.audit_report_generation import generate_audit_report
def process_text(text, filename):
"""
Process the input text by performing various analyses and generating reports.
:param text: The text to be analyzed.
:param filename: The filename associated with the text for version control analysis.
:return: None
"""
print(f"Processing text from {filename}...")
# Step 1: Perform authorship detection
authorship_info = analyze_text(text)
print("Authorship Detection:", authorship_info)
# Step 2: Perform language complexity analysis
language_info = output_metadata(text)
print("Language Complexity Analysis:", language_info)
# Step 3: Perform vocabulary diversity analysis
vocabulary_info = analyze_data(text)
print("Vocabulary Diversity Analysis:", vocabulary_info)
# Combine the analysis results
combined_results = {
"authorship_info": authorship_info,
"language_info": language_info,
"vocabulary_info": vocabulary_info
}
print("Combined Analysis Results:", combined_results)
# Step 4: Apply style morphing (if applicable)
style_morphed_text = apply_style_morphing(text, style_parameters={})
print("Style-Morphed Text:", style_morphed_text)
# Step 5: Generate audit report based on version control
audit_report = generate_audit_report(os.path.join("test_data", filename))
if audit_report:
print("Audit Report:", audit_report)
else:
print(f"No version control data found for '{filename}'.")
def main():
"""
Main function to execute the text processing and reporting workflow.
:return: None
"""
# Directory containing the test data files
test_data_dir = "test_data"
# Loop through all text files in the test data directory
for filename in os.listdir(test_data_dir):
if filename.endswith('.txt'): # Process only .txt files
with open(os.path.join(test_data_dir, filename), 'r') as file:
text = file.read()
process_text(text, filename)
if __name__ == "__main__":
main()