Sapling Logo

Grammar Checking in Perl

Perl

Perl is a family of high-level interpreted scripting languages, including Perl 5 and Perl 6, which was renamed to Raku. It is popular as a scripting language because of its built-in regular expression and string parsing functionality.

Sapling: AI Writing Assistant

With Sapling, you can add grammar or spell checking functionality to an existing Perl application.

This page demonstrates a quick way to integrate grammar and spell checking functionality into a Perl application using Sapling's API. If you are not looking for a Perl guide, click here for guides for other programming languages.

Sapling does not currently maintain a Perl-specific SDK, but you can access the Sapling Grammar Checking HTTP API using any programming language that supports HTTP POST requests. An example is shown below.

Setup Steps

Perl Grammar Check Quickstart

use Encode qw(encode_utf8);
use HTTP::Request ();
use JSON::MaybeXS qw(encode_json);
use MIME::Base64;


my $url = 'https://testapi.com/webapi/AddData';
my $header = ['Content-Type' => 'application/json; charset=UTF-8'];
my $data = {key=> 'API_KEY', text=> 'Lets get started', 'session_id' => "Test Document UUID"};
my $encoded_data = encode_utf8(encode_json($data));
my $r = HTTP::Request->new('POST', $url, $header, $encoded_data);
print $r->responseContent();

Returned result:

{
    "edits":[
      {
          "end":4,
          "error_type":"R:OTHER",
          "general_error_type":"Other",
          "id":"aa5ee291-a073-5146-8ebc-c9c899d01278",
          "replacement":"Let's",
          "sentence":"Lets get started!",
          "sentence_start":0,
          "start":0
      }
    ]
}

Documentation

Addtional parameters and Sapling's full API documentation can be accessed here: https://sapling.ai/docs