The translate-client Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The translate-client Reference Manual

This is the translate-client Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Tue Jan 09 15:53:40 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Translate Client is a library for interfacing with an http-protocol web-server that handles text translation between languages. List of Web Servers:

  Google Translate
    Website: https://cloud.google.com/translate/docs/translating-text
    Requirements: Google Cloud service API Key
    Status: Functioning
  Microsoft Translator
    Website: http://docs.microsofttranslator.com/text-translate.html
    Requirements: azure account and key
    Status: Future development 

This project depends on Alexandria (utilities), Dexador (http client), quri (uri generator), yason (json parsing) and assoc-utils. If you prefer to use a different http client, json library or uri generator, please open an issue.

This project is under the MIT license.

The goal of this project is to provide a common lisp client interface to web-server translation services while at the same time overcoming the limitations of these services.  For example, Google Translate has a stated 2000 character limit for the entire HTTP Request (though the real limit seems somewhere above 5000).  If the requested translation(s) surpass this limit, the software will seemlessly divide the translations into multiple requests.

Exported symbols:
  Parameters:
    *uri-scheme* : the google translation api scheme
    *uri-host* : the google translation api host
    *uri-path* : the google translation api path
    *google-api-key* : the default google cloud api key. You need your own key
      and should be set in your own code.
    *uri-char-limit* : google states that the uri must not pass 2000 characters
    *source-language* : the default source language to be translated from.
      can be a string or keyword. must be an ISO-639-1 identifier
    *target-language* : the target language to be translated to. can be a
      string or keyword. must be an ISO-639-1 identifier
    *translation-format* : the translation format of the translated text.
      Must be :html for html or :text for plain-text
  Functions:  
    translate : (strings &key source target api-key format)
      Translates the string(s) from one language to another.
      Returns a translated string if given a string
        or the list of translated strings if given a list.
      The parameter strings is either a string or a list of strings.
      Keys source and target are strings or keywords and must be ISO-639-1
        language identifiers. Defaults to *source-language* and *target-language*
      Key api-key is a string and must be a valid google cloud api key.
        Defaults to *google-api-key*
      Key format needs to be either :html or :text
        Defaults to *translation-format*
    translate-to-alist : (strings &key source target api-key format)
      similar to translate but returns an association list of translation pairs.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 translate-client

Author

andy peterson

License

MIT

Description

A client to online web-server translators, currently only google translate

Dependencies
Source

translate-client.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 translate-client.asd

Location

translate-client.asd

Systems

translate-client (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 translate-client/package.lisp

Parent

translate-client (system)

Location

package.lisp

Packages

translate-client


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 translate-client/translate-client.lisp

Dependency

package.lisp (file)

Parent

translate-client (system)

Location

translate-client.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 translate-client

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: *google-api-key*

the default google cloud api key. You need your own key and should be set in your own code.

Package

translate-client

Source

translate-client.lisp (file)

Special Variable: *source-language*

the default source language to be translated from. can be a string or keyword. must be an ISO-639-1 identifier

Package

translate-client

Source

translate-client.lisp (file)

Special Variable: *target-language*

the target language to be translated to. can be a string or keyword. must be an ISO-639-1 identifier

Package

translate-client

Source

translate-client.lisp (file)

Special Variable: *translation-format*

the translation format of the translated text. Must be :html for html or :text for plain-text

Package

translate-client

Source

translate-client.lisp (file)

Special Variable: *uri-char-limit*

google states that the uri must not pass 2000 characters

Package

translate-client

Source

translate-client.lisp (file)

Special Variable: *uri-host*

the google translation api host

Package

translate-client

Source

translate-client.lisp (file)

Special Variable: *uri-path*

the google translation api path

Package

translate-client

Source

translate-client.lisp (file)

Special Variable: *uri-scheme*

the google translation api scheme

Package

translate-client

Source

translate-client.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: translate STRINGS &rest ALL-KEYS &key SOURCE TARGET API-KEY FORMAT

translates the string(s) from the source language to the target language.
The parameter strings is either a string or a list of strings to be translated.
Returns
Parameters source and target are strings or keywords and must be ISO-639-1 language identifiers. Api-key is a string and must be a valid google cloud api key.
format needs to be either :html or :text

Package

translate-client

Source

translate-client.lisp (file)

Function: translate-to-alist STRINGS &rest ALL-KEYS &key SOURCE TARGET API-KEY FORMAT

similar to translate but returns an association list of translation pairs.

Package

translate-client

Source

translate-client.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: divide-into-translation-groups STRINGS &rest ALL-KEYS &key SOURCE TARGET API-KEY FORMAT

returns a list of lists. the inner lists must be one of two things:
A list of strings (only) for a single http-request to translate multiple string or a list of a single list of strings when a single translation string must be divided into parts

Package

translate-client

Source

translate-client.lisp (file)

Function: divide-long-string STR BASE-LENGTH
Package

translate-client

Source

translate-client.lisp (file)

Function: encoded-parameter-length STR
Package

translate-client

Source

translate-client.lisp (file)

Function: json-to-translated-strings JSON-STR

given the json response from google, return the list of translated strings

Package

translate-client

Source

translate-client.lisp (file)

Function: string-ellipsis STR MAX-LENGTH &key CUT-POINT ELLIPSIS

this returns a string with maximum length max-length.
If the given string is larger than max-length, this returns a string with ellipsis in the middle at the cut-point.
If cut-point is nil, the ellipsis is in the middle.
If cut-point is zero, negative or :front, the ellipsis is at the beginning.
If cut-point is too large or :back, the ellipsis is at the end.

Package

translate-client

Source

translate-client.lisp (file)

Function: translate-uri STRINGS &key SOURCE TARGET API-KEY FORMAT

create google uri to translates string(s) from the source language to the target language The parameter strings is either a string or a list of strings.
Parameters source and target are strings or keywords and must be ISO-639-1 language identifiers. Api-key is a string and must be a valid google cloud api key.
format needs to be either :html or :text

Package

translate-client

Source

translate-client.lisp (file)

Function: whitespacep CH
Package

translate-client

Source

translate-client.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Generic functions

Generic Function: google-uri-reader CONDITION
Package

translate-client

Methods
Method: google-uri-reader (CONDITION google-uri-character-limit-error)
Source

translate-client.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Conditions

Condition: google-uri-character-limit-error ()
Package

translate-client

Source

translate-client.lisp (file)

Direct superclasses

error (condition)

Direct methods

google-uri-reader (method)

Direct slots
Slot: google-uri
Initargs

:google-uri

Readers

google-uri-reader (generic function)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   T  
Index Entry  Section

F
File, Lisp, translate-client.asd: The translate-client<dot>asd file
File, Lisp, translate-client/package.lisp: The translate-client/package<dot>lisp file
File, Lisp, translate-client/translate-client.lisp: The translate-client/translate-client<dot>lisp file

L
Lisp File, translate-client.asd: The translate-client<dot>asd file
Lisp File, translate-client/package.lisp: The translate-client/package<dot>lisp file
Lisp File, translate-client/translate-client.lisp: The translate-client/translate-client<dot>lisp file

T
translate-client.asd: The translate-client<dot>asd file
translate-client/package.lisp: The translate-client/package<dot>lisp file
translate-client/translate-client.lisp: The translate-client/translate-client<dot>lisp file

Jump to:   F   L   T  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   D   E   F   G   J   M   S   T   W  
Index Entry  Section

D
divide-into-translation-groups: Internal functions
divide-long-string: Internal functions

E
encoded-parameter-length: Internal functions

F
Function, divide-into-translation-groups: Internal functions
Function, divide-long-string: Internal functions
Function, encoded-parameter-length: Internal functions
Function, json-to-translated-strings: Internal functions
Function, string-ellipsis: Internal functions
Function, translate: Exported functions
Function, translate-to-alist: Exported functions
Function, translate-uri: Internal functions
Function, whitespacep: Internal functions

G
Generic Function, google-uri-reader: Internal generic functions
google-uri-reader: Internal generic functions
google-uri-reader: Internal generic functions

J
json-to-translated-strings: Internal functions

M
Method, google-uri-reader: Internal generic functions

S
string-ellipsis: Internal functions

T
translate: Exported functions
translate-to-alist: Exported functions
translate-uri: Internal functions

W
whitespacep: Internal functions

Jump to:   D   E   F   G   J   M   S   T   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
G   S  
Index Entry  Section

*
*google-api-key*: Exported special variables
*source-language*: Exported special variables
*target-language*: Exported special variables
*translation-format*: Exported special variables
*uri-char-limit*: Exported special variables
*uri-host*: Exported special variables
*uri-path*: Exported special variables
*uri-scheme*: Exported special variables

G
google-uri: Internal conditions

S
Slot, google-uri: Internal conditions
Special Variable, *google-api-key*: Exported special variables
Special Variable, *source-language*: Exported special variables
Special Variable, *target-language*: Exported special variables
Special Variable, *translation-format*: Exported special variables
Special Variable, *uri-char-limit*: Exported special variables
Special Variable, *uri-host*: Exported special variables
Special Variable, *uri-path*: Exported special variables
Special Variable, *uri-scheme*: Exported special variables

Jump to:   *  
G   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   G   P   S   T  
Index Entry  Section

C
Condition, google-uri-character-limit-error: Internal conditions

G
google-uri-character-limit-error: Internal conditions

P
Package, translate-client: The translate-client package

S
System, translate-client: The translate-client system

T
translate-client: The translate-client system
translate-client: The translate-client package

Jump to:   C   G   P   S   T