npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mandarino

v27.8.202-4.3.29

Published

Official Mandarino SDK [TypeScript coming soon]

Downloads

282

Readme

Mandarino

Mandarino API in JS

Install

npm install mandarino@latest

Usage

import { mandarinoApi } from "mandarino";

const mandarino = mandarinoApi({
  apiKey: "OPENAI_API_KEY",
});

// Available Features
const {
  discover,
  listGrammarAnaysis,
  detectLanguage,
  genSentences,
  genConversation,
  getSummary,
  listComponents,
} = mandarino;

Feature Usage Guide

  1. Discover discover
  2. Grammar Analysis listGrammarAnalysis
  3. Detect Langauge detectLanguage
  4. Generate Sentences genSentences
  5. Generate Conversation genConversation
  6. Get Summary getSummary
  7. List Components listComponents

1. Discover

mandarino.discover({ content: "从" }).then((character) => {
  console.log("Char", character);
});

// =>
{
  hanzi: '从',
  tone_level: 2,
  pinyin: 'cóng',
  grammar_type: 'preposition',
  en: 'from/by/since/obey/follow/along/entrust/keep an eye on',
  initial: 'c',
  final: 'ong',
  group: 'cong',
  lang: 'zh',
  discovered_at: 1721593687888
}

2. Grammar Analysis

mandarino
  .listGrammarAnaysis({
    lang: "zh",
    content: "不但…而且…",
  })
  .then((grammarAnalysis) => {
    console.log("grammar-analysis", grammarAnalysis);
  });

//  =>
[
  {
    hanzi: "不但",
    pinyin: "bùdàn",
    en: "not only",
    explanation:
      "Expresses a contrast between two elements, emphasizing that the first mentioned condition is true and the second condition is also true.",
  },
  {
    hanzi: "而且",
    pinyin: "érqiě",
    en: "but also",
    explanation:
      "Connects two clauses or phrases, indicating an additional or sequential relationship, implying that there is another relevant point to be mentioned.",
  },
  { hanzi: "...", pinyin: "...", en: "...", explanation: "..." },
];

3. Detect Language

mandarino.detectLanguage({ content: "从" }).then((lang) => {
  console.log("lang", lang);
});

// => 'zh'

4. Generate Sentences

mandarino.genSentences({ content: "从" }).then((sentences) => {
  console.log("sentences", sentences);
});

// =>
[
  {
    hanzi: "从这里开始。",
    pinyin: "Cóng zhèli kāishǐ.",
    en: "Start from here.",
    explanation:
      "In this sentence, 从 means 'from' and 这里 means 'here'. Combined, 从这里开始 means 'Start from here'.",
    lang: "zh",
    component: "从",
  },
  {
    hanzi: "从左往右看。",
    pinyin: "Cóng zuǒ wǎng yòu kàn.",
    en: "Look from left to right.",
    explanation:
      "Here, 从 means 'from', 左 means 'left', 右 means 'right', and 看 means 'look'. Combined, 从左往右看 means 'Look from left to right'.",
    lang: "zh",
    component: "从",
  },
  {
    hanzi: "从小学就喜欢阅读。",
    pinyin: "Cóng xiǎoxué jiù xǐhuān yuèdú.",
    en: "Have loved reading since elementary school.",
    explanation:
      "In this sentence, 从 means 'from', 小学 means 'elementary school', 就 means 'since', 喜欢 means 'like', and 阅读 means 'reading'. Combined, 从小学就喜欢阅读 means 'Have loved reading since elementary school'.",
    lang: "zh",
    component: "从",
  },
  {
    hanzi: "从山上往下走。",
    pinyin: "Cóng shānshàng wǎng xià zǒu.",
    en: "Walk down from the mountain.",
    explanation:
      "Here, 从 means 'from', 山上 means 'mountain top', 往下 means 'downwards', and 走 means 'walk'. Combined, 从山上往下走 means 'Walk down from the mountain'.",
    lang: "zh",
    component: "从",
  },
  {
    hanzi: "从星期一到星期五。",
    pinyin: "Cóng xīngqī yī dào xīngqīwǔ.",
    en: "From Monday to Friday.",
    explanation:
      "In this sentence, 从 means 'from', 星期一 means 'Monday', 到 means 'to', and 星期五 means 'Friday'. Combined, 从星期一到星期五 means 'From Monday to Friday'.",
    lang: "zh",
    component: "从",
  },
];

5. Generate Conversation


mandarino
  .genConversation({
    lang: "zh",
    topic: "Booking a High Speed Return Ticket",
    subtopic: "Travel",
  })
  .then((conversations) => {
    console.log("convos", conversations);
  });



// =>
{
  title: 'Booking a High Speed Return Ticket - Travel',
  topic: 'travel',
  subtopic: 'booking a high speed return ticket',
  lang: 'zh',
  conversation: [
    {
      input: '你好,请问有高铁往返票吗?',
      en: 'Hello, do you have high-speed return tickets available?',
      speaker: 'Customer',
      roman: 'Nǐ hǎo, qǐngwèn yǒu gāotiě wǎngfǎn piào ma?'
    },
    {
      input: '对不起,高铁往返票已经售罄了。',
      en: "I'm sorry, the high-speed return tickets are sold out.",
      speaker: 'Staff',
      roman: 'Duìbùqǐ, gāotiě wǎngfǎn piào yǐjīng shòuqìng le.'
    },
    {
      input: '那有其他时间的票吗?',
      en: 'Do you have tickets available for other times?',
      speaker: 'Customer',
      roman: 'Nà yǒu qítā shíjiān de piào ma?'
    },
    {
      input: '是的,我们还有晚点的高铁票。',
      en: 'Yes, we still have high-speed tickets for later times.',
      speaker: 'Staff',
      roman: 'Shì de, wǒmen hái yǒu wǎndiǎn de gāotiě piào.'
    }
  ],
  responseTime: 4231.86862501502
}

6. Get Summary

mandarino
  .getSummary({
    lang: "zh",
    content: "不但…而且…",
  })
  .then((summary) => {
    console.log("summary", summary);
  });

// =>
`
Explanation:
The phrase "不但...而且..." is used to express a contrast or addition between two elements or actions. It typically emphasizes that in addition to the first mentioned element, there is also the second mentioned element.

Possible use cases:
This phrase can be used to highlight a dual effect, action, or situation, emphasizing that both aspects are relevant or important. For example, "不但漂亮,而且聪明" means "Not only beautiful, but also smart." This structure can be applied in various contexts such as describing qualities of a person, product features, or comparing different options.
`;

7. List Components

listComponents is a synchronous function that returns a list of components

const components = mandarino.listComponents();

console.log(components[0]);

// =>
{
    initial: 'd',
    en: 'electric',
    pinyin: 'diàn',
    group: 'diàn',
    data_version: '2023-10-07',
    updated_at: 1700684107708,
    count: 291,
    grammar_type: 'noun',
    tone_level: 4,
    level: 43,
    final: 'iàn',
    id: '8e13afa5-f14b-5a14-ab4e-acbe51281b58',
    hanzi: '电',
    nmmIndex: 100,
    hskIndex: 41
}