Content Quality Analysis in Jupyter Notebooks

The NextGen documentation is still under construction.

Transform how you analyze content quality with the Acrolinx NextGen API Python SDK. This interactive notebook demonstrates how to integrate Acrolinx’s powerful content analysis directly into your data science workflow.

When to Use This Integration

This notebook approach is ideal when you need to:

  • Analyze content quality programmatically within your data analysis workflow
  • Generate quality reports for documentation, marketing copy, or technical content
  • Integrate content checks into data science pipelines
  • Visualize writing metrics alongside other analytics
  • Batch process multiple documents for quality assessment

What You’ll Learn

In this tutorial, you’ll discover how to:

  1. Set up the Acrolinx Python SDK
  2. Submit content for quality analysis
  3. Poll for and retrieve detailed results
  4. Interpret quality scores across multiple dimensions
  5. Process specific issues and suggestions

Prerequisites

Before you begin, ensure you have:

  • An Acrolinx NextGen API key (request beta access)
  • Python 3.8 or higher
  • Basic familiarity with Jupyter Notebooks

Step-by-Step Implementation

1

Setup and Installation

First, install the official Acrolinx NextGen API package and import the necessary modules:

1# Install the official Acrolinx NextGen API package
2!pip install acrolinx-nextgen-api
3
4from acrolinx import Acrolinx
5import json
6import time
7import tempfile
8import os
9
10print("✅ Acrolinx SDK imported successfully!")
2

Initialize the Client

Configure your Acrolinx client with your API key:

1# ❗ FOR YOU: Put your API key here
2ACROLINX_API_KEY = "your-api-key-here"
3
4# Initialize the Acrolinx client
5client = Acrolinx(
6 token=ACROLINX_API_KEY,
7)
8
9print("🚀 Acrolinx SDK client initialized!")

Store your API key securely. In Colab, use the secrets feature. In local notebooks, consider using environment variables.

3

Prepare Your Content

Set up the text you want to analyze. This example uses a business communication about remote work:

1# ❗ FOR YOU: Put the text you want to check here
2# Sample text to analyze - a business communication about remote work
3sample_text = """
4Remote work has fundamentally transformed how organiztions operate in the modern busness landscape. Companies worldwide have discovered that distributed teams can maintain high levels of productivity while offering employees greater flexibility and work-life balance. This shift has necessitated the adoption of new technologies, communication protocols, and management strategies to ensure seamless collaboration across different time zones and locations.
5
6However, the transition to remote work also presents unique challenges that require careful consideration. Issues such as maintaining team cohesion, ensuring effective knowledge transfer, and preserving company culture become more complex when employees are physically separated. Organizations that successfully navigate these challenges typically invest in robust digital infrastructure, establish clear communication guidelines, and prioritize regular virtual team-building activities to foster meaningful connections among team members.
7""".strip()
8
9print("📝 Sample text prepared:")
10print("-" * 60)
11print(sample_text)
12print("-" * 60)
13print(f"Text length: {len(sample_text)} characters")
4

Configure Check Parameters

Choose your style guide, tone, and dialect for the analysis:

1# ❗ FOR YOU: Choose your parameters for the check and set them here
2# See the docs for allowed values
3
4style_guide = "microsoft"
5tone = "business"
6dialect = "american_english"

Available style guides include “microsoft”, “AP”, “chicago”, and custom guides. Check the API documentation for all options.

5

Submit Content for Analysis

Create a style check using the SDK. The API requires file upload, so we create a temporary file:

1# Create a style check using the SDK
2print("🔍 Creating style check with Acrolinx SDK...")
3
4try:
5 # Create temporary file for upload (API requires file upload)
6 with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', delete=False) as tmp_file:
7 tmp_file.write(sample_text)
8 temp_file_path = tmp_file.name
9
10 print(f"📁 Created temporary file: {temp_file_path}")
11
12 # Submit the document for analysis
13 with open(temp_file_path, 'rb') as file_obj:
14 check_response = client.style_suggestions.create_style_suggestion(
15 file_upload=file_obj,
16 style_guide=style_guide,
17 tone=tone,
18 dialect=dialect
19 )
20
21 # Clean up temporary file
22 os.unlink(temp_file_path)
23 print("🗑️ Temporary file cleaned up")
24
25 # Display initial response
26 print("\n📊 Style Check Submitted:")
27 print(f"Status: {check_response.status}")
28 print(f"Workflow ID: {check_response.workflow_id}")
29
30 # Store workflow ID for polling
31 workflow_id = check_response.workflow_id
32
33except Exception as e:
34 print(f"❌ Error creating style check: {e}")
35 # Clean up if error occurs
36 if 'temp_file_path' in locals() and os.path.exists(temp_file_path):
37 os.unlink(temp_file_path)
38 print("🗑️ Temporary file cleaned up after error")
6

Poll for Results

Wait for the analysis to complete and retrieve the results:

1# Poll for completion and get results
2if 'workflow_id' in locals():
3 print(f"⏳ Polling for completion of workflow: {workflow_id}")
4
5 max_attempts = 15
6 for attempt in range(max_attempts):
7 try:
8 # Check status
9 result = client.style_suggestions.get_style_suggestion(workflow_id=workflow_id)
10
11 print(f" Attempt {attempt + 1}: Status = {result.status}")
12
13 if result.status == 'completed':
14 print("\n✅ Analysis completed!")
15 final_result = result
16 break
17 elif result.status == 'failed':
18 print("\n❌ Analysis failed!")
19 break
20
21 # Wait before next attempt
22 time.sleep(3)
23
24 except Exception as e:
25 print(f" Error on attempt {attempt + 1}: {e}")
26 # If we get validation errors, try to continue polling
27 if "validation error" in str(e).lower():
28 print(" (Continuing despite validation error...)")
29 time.sleep(3)
30 continue
31 else:
32 break
33
34 if attempt >= max_attempts - 1:
35 print("⏰ Timeout waiting for completion")
36else:
37 print("❌ No workflow_id available")
7

View and Interpret Results

Display the comprehensive analysis results including scores and issues:

1print("\n" + "=" * 60)
2print("📋 ACROLINX ANALYSIS RESULTS")
3print("=" * 60)
4
5scores = final_result.scores
6print("📊 Quality Scores:")
7print(f" 🏆 Quality: {scores.quality.score}/100")
8print(f" 📝 Grammar: {scores.grammar.score}/100")
9print(f" 📏 Style Guide: {scores.style_guide.score}/100")
10print(f" 🎯 Tone: {scores.tone.score}/100")
11print(f" 📚 Terminology: {scores.terminology.score}/100")
12
13if final_result.issues:
14 issues = final_result.issues
15 print(f"\n🔧 Issues Found: {len(issues)}")
16
17 if len(issues) > 0:
18 print("\nTop 10 Issues:")
19 print("issue - suggestion - category")
20 print("=" * 60)
21 for i, issue in enumerate(issues[:10]):
22 print(f"{i+1}. \"{issue.original}\" → \"{issue.suggestion}\" - {issue.category}")
23
24 print(f"\n📊 Analysis Status: {final_result.status}")
25 print(f"📊 Workflow ID: {workflow_id}")

Example Output

When you run this notebook, you’ll see results like:

============================================================
📋 ACROLINX ANALYSIS RESULTS
============================================================
📊 Quality Scores:
🏆 Quality: 61/100
📝 Grammar: 48/100
📏 Style Guide: 48/100
🎯 Tone: 86/100
📚 Terminology: 100/100
🔧 Issues Found: 13
Top 10 Issues:
issue - suggestion - category
============================================================
1. "organiztions" → "organizations" - grammar
2. "busness" → "business" - grammar
3. "organiztions" → "organizations" - simple_vocab
4. "necessitated" → "required" - simple_vocab
5. "has necessitated" → "requires" - sentence_structure
...

Understanding the Scores

  • Quality Score: Overall content quality (0-100)
  • Grammar Score: Correctness of grammar and spelling
  • Style Guide Score: Adherence to the selected style guide
  • Tone Score: Consistency with the specified tone
  • Terminology Score: Proper use of domain-specific terms

Next Steps

Now that you’ve seen the Acrolinx Python SDK in action, you can:

1. Extend the Analysis

  • Process multiple documents in a loop
  • Export results to CSV or JSON for further analysis
  • Create visualizations of quality metrics over time

2. Integrate with Your Workflow

  • Add Acrolinx checks to your CI/CD pipeline
  • Build automated quality reports for documentation
  • Create custom functions for specific content types

Tips for Success

Performance: For large documents, consider splitting them into smaller chunks to improve processing time and avoid timeouts.

Error Handling: Always implement proper error handling and cleanup, especially when working with temporary files.

API Limits: Be mindful of rate limits. Implement exponential backoff when processing multiple documents.

Ready to improve your content quality? Request beta access to get started with the Acrolinx NextGen API!