-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze_text.py
46 lines (36 loc) · 1.52 KB
/
analyze_text.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
# analyze_text.py
from authorship_detection import detect_authorship
from language_analysis import analyze_language_complexity
from vocabulary_analysis import analyze_vocabulary_diversity
def analyze_text(text):
"""
Analyzes the text for authorship, language complexity, and vocabulary diversity.
Parameters:
- text (str): The input text to analyze.
Returns:
- dict: The analysis results.
"""
authorship_info = detect_authorship(text)
language_info = analyze_language_complexity(text)
vocabulary_info = analyze_vocabulary_diversity(text)
return {
"authorship_info": authorship_info,
"language_info": language_info,
"vocabulary_info": vocabulary_info
}
def output_metadata(analysis_results):
"""
Outputs the combined analysis results metadata.
Parameters:
- analysis_results (dict): The combined analysis results.
"""
print("\n--- Analysis Results ---\n")
print("Authorship Detection:")
print(f"Score: {analysis_results['authorship_info']['score']:.2f}")
print(analysis_results['authorship_info']['summary'])
print("\nLanguage Complexity:")
print(f"Average Word Length: {analysis_results['language_info']['avg_word_length']:.2f}")
print(analysis_results['language_info']['language_complexity'])
print("\nVocabulary Diversity:")
print(f"Unique Word Ratio: {analysis_results['vocabulary_info']['unique_word_ratio']:.2f}")
print(analysis_results['vocabulary_info']['vocabulary_diversity'])