Split by Topic

Splits input content by topics.

Josh: DIALOGUE-SEGMENTATION Do you like math?
Mellisa: I like it but I'm not so good at it
Josh: what was your last grade?
Mellisa: I got a C last year.

Josh: DIALOGUE-SEGMENTATION Did you hear about Donald Trump last issue?
Mellisa: No. What did he do this time?

📘

Use Split by Topic Skill to:

👍

Benchmarks

Coming soon...

Output labels

Type
dialogue-segment

Parameters

This skill takes no parameters as input.

Example

Request

curl -X POST \
'https://api.oneai.com/api/v0/pipeline' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'api-key: <YOUR-API-KEY-HERE>' \
-d '{
    "input": [{ "speaker": "Josh", "utterance": "Do you like math?", "timestamp": "0:00" }, { "speaker": "Mellisa", "utterance": "I like it but I'\''m not so good at it", "timestamp": "0:00" }, { "speaker": "Josh", "utterance": "...", "timestamp": "..." }],
    "input_type": "conversation",
        "content_type": "application/json",
    "steps": [
      {
        "skill": "dialogue-segmentation"
      }   
    ]
}'
const OneAI = require("oneai");

const oneai = new OneAI("<YOUR-API-KEY-HERE>");
const conversation = new oneai.Conversation(
  [{ "speaker": "Josh", "utterance": "Do you like math?", "timestamp": "0:00" }, { "speaker": "Mellisa", "utterance": "I like it but I'm not so good at it", "timestamp": "0:00" }, { "speaker": "Josh", "utterance": "...", "timestamp": "..." }]
);

const pipeline = new oneai.Pipeline(
    oneai.skills.splitByTopic(),
);

pipeline.run(conversation).then(console.log);
import oneai

oneai.api_key = "<YOUR-API-KEY-HERE>"
pipeline = oneai.Pipeline(
  steps = [
        oneai.skills.SplitByTopic(),
  ]
)

conversation = oneai.Conversation(
  [{ "speaker": "Josh", "utterance": "Do you like math?", "timestamp": "0:00" }, { "speaker": "Mellisa", "utterance": "I like it but I'm not so good at it", "timestamp": "0:00" }, { "speaker": "Josh", "utterance": "...", "timestamp": "..." }]
)

output = pipeline.run(conversation)

Response

{
  "input_text": "Josh:\nDo you like math?\n\nMellisa:\nI like it but I'm not so good at it\n\nJosh:\nwhat was your last grade?\n\nMellisa:\nI got a C last year.\n\nJosh:\nDid you hear about Donald Trump last issue?\n\nMellisa:\nNo. What did he do this time?\n\n",
  "status": "success",
  "output": [
    {
      "text_generated_by_step_name": "input",
      "text_generated_by_step_id": 0,
      "text": "Josh:\nDo you like math?\n\nMellisa:\nI like it but I'm not so good at it\n\nJosh:\nwhat was your last grade?\n\nMellisa:\nI got a C last year.\n\nJosh:\nDid you hear about Donald Trump last issue?\n\nMellisa:\nNo. What did he do this time?\n\n",
      "labels": [
        {
          "type": "dialogue-segment",
          "skill": "dialogue-segmentation",
          "speaker": "Mellisa,Josh",
          "data": {
            "subheading": "Do you like math?"
          },
          "span_text": "Do you like math?\n\nMellisa:\nI like it but I'm not so good at it\n\nJosh:\nwhat was your last grade?\n\nMellisa:\nI got a C last year.",
          "span": [
            6,
            133
          ],
          "output_spans": [
            {
              "section": 0,
              "start": 0,
              "end": 17
            },
            {
              "section": 1,
              "start": 0,
              "end": 35
            },
            {
              "section": 2,
              "start": 0,
              "end": 25
            },
            {
              "section": 3,
              "start": 0,
              "end": 20
            }
          ]
        },
        {
          "type": "dialogue-segment",
          "skill": "dialogue-segmentation",
          "speaker": "Mellisa,Josh",
          "data": {
            "subheading": "Did you hear about Donald Trump?"
          },
          "span_text": "Did you hear about Donald Trump last issue?\n\nMellisa:\nNo. What did he do this time?",
          "span": [
            141,
            224
          ],
          "output_spans": [
            {
              "section": 4,
              "start": 0,
              "end": 43
            },
            {
              "section": 5,
              "start": 0,
              "end": 29
            }
          ]
        }
      ]
    }
  ],
  "stats": {
    "concurrency_wait_time": 0,
    "total_running_jobs": 1,
    "total_waiting_jobs": 0
  }
}
{
  text: '[0:00] Josh:\n' +
    'Do you like math?\n' +
    '\n' +
    '[0:00] Mellisa:\n' +
    "I like it but I'm not so good at it\n" +
    '\n' +
    '[...] Josh:\n' +
    '...\n' +
    '\n',
  segments: [
    {
      type: 'dialogue-segment',
      skill: 'dialogue-segmentation',
      speaker: 'Mellisa,Josh',
      span_text: 'Do you like math?\n' +
        '\n' +
        '[0:00] Mellisa:\n' +
        "I like it but I'm not so good at it\n" +
        '\n' +
        '[...] Josh:\n' +
        '...',
      span: [ 13, 100 ],
      output_spans: [
        { section: 0, start: 0, end: 17 },
        { section: 1, start: 0, end: 35 },
        { section: 2, start: 0, end: 3 }
      ],
      data: { 
        subheading: 'Do you like math?' 
      }
    }
  ]
}

Additional Data

Each segment will contain a subheading, generated by the Subheading skill in the data field


Did this page help you?