Skip to content

Repository files navigation

Syntax Analyzer

Below are the API specifications for the Syntax Analyzer project, offering features such as syntax analysis and random sentence generation.

Analyze Sentence Syntax

This endpoint uses specified AI models to analyze the syntax of tokenized sentences, breaking them down into grammatical elements for detailed structural insights.

Endpoint

POST /analyzer

Request Body

FieldTypeOptionsRequiredDescriptionConstraints
modelstringprimary, primary-ft, fast-ftYesAnalysis model key (provider model alias)One of: primary, primary-ft, fast-ft
sentenceArray<string>N/AYesTokens for analysisRange: 2~20 tokens

Example Request

{
"model": "fast-ft",
"sentence": ["My", "name", "is", "John", "."]
}

Quota Consumption

  • model=primary: 2 analysis credits
  • model=primary-ft: 2 analysis credits
  • model=fast-ft: 1 analysis credit

Response

Analysis Data Model

typeAnalysisSource='user'|'sample';typeISODateString=string;typeConstituentType='clause'|'phrase'|'token';typeTConstituent={id: number;// Random 9-digit numberelementId: number;// Constituent IDlabel: string;// Grammatical label, e.g., "subject"abbreviation: string;// Abbreviation, e.g., "s"type: ConstituentType;// Type of constituent};typeTSegment={id: number;// Random 9-digit numberbegin: number;// Start indexend: number;// End indexconstituents: TConstituent[];// Segment constituentschildren: TSegment[];// Sub-segments};typeTAnalysis={id: string;// Random 21-byte stringsource: AnalysisSource;// Data sourcecreatedAt: ISODateString;// ISO 8601 timestampsentence: string[];// Tokenized sentencerootSegment: TSegment;// Root segmentisAnalyzedByGPT: boolean;// AI-analyzed status};
200 OK
{
"id": "YW6AX-AOZb2-xYXt05xkn",
"source": "user",
"createdAt": "2023-05-10T23:08:08.000Z",
"sentence": ["My", "name", "is", "John", "."],
"rootSegment": {
"id": 840296172,
"begin": 0,
"end": 5,
"constituents": [],
"children": [
{
"id": 987654321,
"begin": 0,
"end": 2,
"constituents": [
{
"id": 456789123,
"elementId": 1,
"label": "subject",
"abbreviation": "s",
"type": "token"
}
],
"children": []
},
{
"id": 789123456,
"begin": 2,
"end": 3,
"constituents": [
{
"id": 321654987,
"elementId": 2,
"label": "verb",
"abbreviation": "v",
"type": "token"
}
],
"children": []
},
{
"id": 654321789,
"begin": 3,
"end": 4,
"constituents": [
{
"id": 654987321,
"elementId": 5,
"label": "object",
"abbreviation": "o",
"type": "token"
}
],
"children": []
},
{
"id": 321789654,
"begin": 4,
"end": 5,
"constituents": [],
"children": []
}
]
},
"isAnalyzedByGPT": true
}
400 Bad Request
{
"errors": [
{
"type": "field",
"value": "value that caused the error",
"msg": "Error description",
"path": "field_name",
"location": "body"
}
]
}

Generate random sentences

This endpoint generates random sentences, optionally constrained by sentence count, character limit, and topics.

Endpoint

GET /analyzer/random-sentences

Request Parameters

FieldTypeRequiredDefaultDescriptionConstraints
sent_countnumberNo3Quantity of sentencesRange: 1~5
max_charsnumberNo80Character limit per sentenceRange: 10~80
topicsArray<string>No[]Topics to include in sentencesMax 3 topics

Response

200 OK
[
"Apples are a popular fruit that come in many different varieties.",
"Apple trees are typically grown in orchards for commercial production.",
"Apple cider is a refreshing beverage made from pressed apples.",
]
400 Bad Request
{
"errors": [
{
"type": "field",
"value": "value that caused the error",
"msg": "Error description",
"path": "field_name",
"location": "query"
}
]
}

Check remaining counts

This endpoint provides remaining user quotas for syntax analysis and random sentences, resetting daily to 10 and 20, respectively.

Endpoint

GET /analyzer/remaining-counts

Response

200 OK
{
"analysis": 10,
"random_sentence": 20
}
  • analysis : Remaining count for syntax analysis
  • random_sentence : Remaining count for random sentence generation
400 Bad Request
{
"status": "error",
"message": "Error description"
}

About

Personal Project Server

Topics

Resources

Security policy

Stars

1 star

Watchers

1 watching

Forks

Used by

Contributors

Languages