Lem/Docs

humanize section

Rewrite the prose of one section of a paper's manuscript in a voice, keeping its formulas, citations and commands.

Invocation#

Shell
lem-cli humanize section <id-or-title> --section <title-or-label> | --every-section [--write] --generator stado|local|declared --voice <name> | --style <s> --language <l> --candidates <n> --max-words-per-chunk <n> --temperature <t> --seed <n> --minimum-quality <q> [...]

Inputs and options#

  • id-or-title selects the paper; its words may stand unquoted.
  • --section names the section by its heading's title, compared without case, or by the label after the heading. The main manuscript and every file it includes are searched.
  • --every-section, instead of --section, rewrites every section in the order they stand, so a whole paper is rewritten in one run: a section holding sub-sections in its own text before the first of them, each sub-section in its turn.
  • --write replaces the section in its file with the rewrite; without it the file is not touched and the rewrite is only printed.
  • Every setting of humanize rewrite is taken and checked the same way, --voice among them.

Output and state#

The section runs from its heading to the next heading of the same or a higher level, the appendix, the bibliography or the end of the document. Its comments, environments, displayed and inline formulas, commands with their arguments (citations and references among them), escaped characters and ties are replaced by numbered placeholders, ⟦0⟧, ⟦1⟧ and so on, before Skryba sees the text, and put back after, so only sentences are rewritten.

Prints `paper_id`, `file`, `section` (the heading's title), `line`, `kept` (how many spans were kept aside), `original`, `rewritten`, `written` and `rewrite`, Skryba's answer. With --write the file is replaced only while it still holds what was read.

With --every-section each section is found again by its label or title just before it is rewritten, so one written earlier moves none of the later ones. It prints `paper_id`, `rewritten` (each section's answer as above; `original` of a section holding others is its own text), `through` (each heading holding others whose own text holds no prose, which is left as it is) and `refused` (each section a rewrite was refused for, with the refusal's sentence); a refused section does not stop the next.

`GET /papers/<id>/sections` lists the headings, `POST /papers/<id>/sections/rewrite` with `{section, write, rewrite}` (rewrite being the body POST /ai-text/humanize takes) answers the same, and `POST /papers/<id>/sections/write` with `{section, original, rewritten}` writes a rewrite already shown, only while the section still holds `original`. Lem Desktop's AI text panel offers this as Rewrite a section: it shows the rewrite first, and Write into the paper writes that same text. `POST /papers/<id>/sections/rewrite-every` with `{write, rewrite}` answers what --every-section prints, its refused sections in `refused` with status 200, and the panel's Rewrite every section into the paper sends it with `write` true.

Refusals#

  • No paper, neither or both of --section and --every-section, or an option it does not take refuse with “humanize section needs the paper and either --section naming the section or --every-section, …”, exit 2, before the registry is read; no --generator is refused as for humanize rewrite.
  • With --every-section, once every section was tried, any refused ends the run as `lem.humanize.section.sections-refused`, naming them, after the answer is printed; each one's own cause and fix are in `refused`.
  • A paper with no main LaTeX file is `lem.humanize.section.source-absent`; a section no heading names, listing every heading with its label and line, is `section-unknown`; one several headings name, listing them, is `section-ambiguous` (exit 2); a section of formulas, figures and commands alone is `prose-none`.
  • A rewrite that loses, repeats or invents a placeholder is `placeholder-lost`, naming each placeholder and what it stood for, with Skryba's rewrite; nothing is written. A file that changed while it was rewritten is `source-changed`, and one that cannot be replaced is `source-unwritten`; it is left as it was.