和顺 / 影核 返回所属 Agent
YH-03.01

场次拆解

原能力

定位情节、人物、场景、动作或交互节点,标记原剧本位置及版本。(细化版 p.12–13)

首选项目

Fountain.js(MIT)。 Fountain.js

接入说明

改选源码公开的 Fountain.js。原候选 screenplay-fountain 的已核对公开提交只有 README、许可证和忽略文件。Fountain.js 输出场次、人物等 token。自由格式、中文提示和业务 ID 仍需适配。

匹配范围

对符合 Fountain 的输入输出场次标题、场号、动作与人物 token,并保留可进一步分组的原始顺序。

源码

Fountain.js · fountain.parse = function

fountain.js · 275–284 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
  fountain.parse = function (script, tokens, callback) {
    return parse(script, tokens, callback);
  };

  if (typeof module !== 'undefined') {
    module.exports = fountain;
  } else {
    this.fountain = fountain;
  }  
}).call(this);
  • // Copyright (c) 2012 Matt Daly
  • title_page: /^((?:title|credit|author[s]?|source|notes|draft date|date|contact|copyright)\:)/gim,

Fountain.js · var tokenize = function

fountain.js · 54–67 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
  var tokenize = function (script) {
    var src    = lexer(script).split(regex.splitter)
      , i      = src.length, line, match, parts, text, meta, x, xlen, dual
      , tokens = [];

    while (i--) {
      line = src[i];
      
      // title page
      if (regex.title_page.test(line)) {
        match = line.replace(regex.title_page, '\n$1').split(regex.splitter).reverse();
        for (x = 0, xlen = match.length; x < xlen; x++) {
          parts = match[x].replace(regex.cleaner, '').split(/\:\n*/);
          tokens.push({ type: parts[0].trim().toLowerCase().replace(' ', '_'), text: parts[1].trim() });
  • // Copyright (c) 2012 Matt Daly
  • title_page: /^((?:title|credit|author[s]?|source|notes|draft date|date|contact|copyright)\:)/gim,
接口用法示意
const scenes = fountain.parse(script, true).tokens.filter(token => token.type === 'scene_heading')

实现与验收要点

其他剧本格式、素材/制作语义抽取、原文位置与版本关系。