Add enhanced analysis with selective field analysis and category proposer
New Features: - Selective field analysis: Choose which fields to analyze (title, meta_description, categories, site) - In-place CSV updates: Update input CSV with new columns (automatic backup created) - Category proposer: Dedicated command for AI-powered category suggestions New Commands: - seo analyze -f title categories: Analyze specific fields only - seo analyze -u: Update input CSV with recommendations - seo category_propose: Propose categories based on content New Scripts: - enhanced_analyzer.py: Enhanced AI analyzer with selective analysis - category_proposer.py: Dedicated category proposal tool CLI Options: - --fields, -f: Specify fields to analyze - --update, -u: Update input CSV (creates backup) - --output, -o: Custom output file path Output Columns: - proposed_title, title_reason (for title analysis) - proposed_meta_description, meta_reason (for meta analysis) - proposed_category, category_reason (for category analysis) - proposed_site, site_reason (for site analysis) - ai_confidence, ai_priority (common to all) Documentation: - ENHANCED_ANALYSIS_GUIDE.md: Complete guide with examples Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -41,6 +41,11 @@ Examples:
|
||||
parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output')
|
||||
parser.add_argument('--dry-run', action='store_true', help='Show what would be done')
|
||||
parser.add_argument('--top-n', type=int, default=10, help='Number of top posts for AI analysis')
|
||||
parser.add_argument('--fields', '-f', nargs='+',
|
||||
choices=['title', 'meta_description', 'categories', 'site'],
|
||||
help='Fields to analyze (for analyze command)')
|
||||
parser.add_argument('--update', '-u', action='store_true', help='Update input file (creates backup)')
|
||||
parser.add_argument('--output', '-o', help='Output file path')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -65,6 +70,7 @@ Examples:
|
||||
'recategorize': cmd_recategorize,
|
||||
'seo_check': cmd_seo_check,
|
||||
'categories': cmd_categories,
|
||||
'category_propose': cmd_category_propose,
|
||||
'approve': cmd_approve,
|
||||
'full_pipeline': cmd_full_pipeline,
|
||||
'status': cmd_status,
|
||||
@@ -110,7 +116,33 @@ def cmd_analyze(app, args):
|
||||
return 0
|
||||
|
||||
csv_file = args.args[0] if args.args else None
|
||||
app.analyze(csv_file)
|
||||
|
||||
# Use enhanced analyzer if fields are specified or update flag is set
|
||||
if args.fields or args.update:
|
||||
from pathlib import Path
|
||||
import sys
|
||||
scripts_dir = Path(__file__).parent.parent.parent / 'scripts'
|
||||
sys.path.insert(0, str(scripts_dir))
|
||||
|
||||
from enhanced_analyzer import EnhancedPostAnalyzer
|
||||
|
||||
if not csv_file:
|
||||
csv_file = app._find_latest_export()
|
||||
|
||||
if not csv_file:
|
||||
print("❌ No CSV file found. Provide one or run export first.")
|
||||
return 1
|
||||
|
||||
print(f"Using enhanced analyzer with fields: {args.fields or 'all'}")
|
||||
analyzer = EnhancedPostAnalyzer(csv_file, analyze_fields=args.fields)
|
||||
output_file = analyzer.run(
|
||||
output_file=args.output,
|
||||
update_input=args.update
|
||||
)
|
||||
print(f"✅ Analysis completed! Results: {output_file}")
|
||||
else:
|
||||
app.analyze(csv_file)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -145,6 +177,37 @@ def cmd_categories(app, args):
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_category_propose(app, args):
|
||||
"""Propose categories for posts."""
|
||||
if args.dry_run:
|
||||
print("Would propose categories for posts using AI")
|
||||
return 0
|
||||
|
||||
csv_file = args.args[0] if args.args else None
|
||||
|
||||
if not csv_file:
|
||||
csv_file = app._find_latest_export()
|
||||
|
||||
if not csv_file:
|
||||
print("❌ No CSV file found. Provide one or run export first.")
|
||||
print(" Usage: seo category_propose <csv_file>")
|
||||
return 1
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
scripts_dir = Path(__file__).parent.parent.parent / 'scripts'
|
||||
sys.path.insert(0, str(scripts_dir))
|
||||
|
||||
from category_proposer import CategoryProposer
|
||||
|
||||
print(f"Proposing categories for: {csv_file}")
|
||||
proposer = CategoryProposer(csv_file)
|
||||
output_file = proposer.run(output_file=args.output)
|
||||
|
||||
print(f"✅ Category proposals saved to: {output_file}")
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_approve(app, args):
|
||||
"""Approve recommendations."""
|
||||
if args.dry_run:
|
||||
@@ -192,10 +255,13 @@ SEO Automation CLI - Available Commands
|
||||
|
||||
Basic Commands:
|
||||
export Export all posts from WordPress sites
|
||||
analyze [csv_file] Analyze posts with AI (optional CSV input)
|
||||
recategorize [csv_file] Recategorize posts with AI (optional CSV input)
|
||||
analyze [csv_file] Analyze posts with AI
|
||||
analyze -f title categories Analyze specific fields only
|
||||
analyze -u Update input CSV with new columns
|
||||
recategorize [csv_file] Recategorize posts with AI
|
||||
seo_check Check SEO quality of titles/descriptions
|
||||
categories Manage categories across all sites
|
||||
categories Manage categories across sites
|
||||
category_propose [csv] Propose categories based on content
|
||||
approve [files...] Review and approve recommendations
|
||||
full_pipeline Run complete workflow: export → analyze → seo_check
|
||||
|
||||
@@ -207,12 +273,18 @@ Options:
|
||||
--verbose, -v Enable verbose logging
|
||||
--dry-run Show what would be done without doing it
|
||||
--top-n N Number of top posts for AI analysis (default: 10)
|
||||
--fields, -f Fields to analyze: title, meta_description, categories, site
|
||||
--update, -u Update input CSV file (creates backup)
|
||||
--output, -o Output file path
|
||||
|
||||
Examples:
|
||||
seo export
|
||||
seo analyze
|
||||
seo analyze output/all_posts_2026-02-16.csv
|
||||
seo approve output/category_assignments_*.csv
|
||||
seo analyze -f title categories
|
||||
seo analyze -u -f meta_description
|
||||
seo category_propose
|
||||
seo approve output/category_proposals_*.csv
|
||||
seo full_pipeline
|
||||
seo status
|
||||
""")
|
||||
|
||||
Reference in New Issue
Block a user