LLineCitrine
製品

ソフトウェアの機能 · 行末の不揃いを最小にする折り返し

01

LineCitrineで残りの行の費用から改行候補を比較し、最初に収まる候補を最適と決め付けません。

01

モデル

OpenAI互換またはAnthropicのエンドポイントを、ベースURLと必要なAPIキーで設定し、接続をテストします。ローカルのモデルサーバーは起動が必要です。リモートツールは別途データを送信する場合があります。

02

プロジェクト

フォルダーを選び、編集前に関連ファイルを読むようアシスタントに依頼します。作業の目的と変更範囲を明確にしてください。

03

変更内容

変更内容とコマンド出力を確認します。結果を採用する前にプロジェクトの検証を実行してください。生成コードが自動的にテスト済みになるわけではありません。

行末の不揃いを最小にする折り返し

● ● ●LineCitrine●
ワークフロー · 行末の不揃いを最小にする折り返し ×
def wrap_words(words, width):
    words = tuple(words)
    if type(width) is not int or not 1 <= width <= 80 or len(words) > 100:
        raise ValueError("wrap.limit")
    if any(type(w) is not str or not w or len(w) > width or any(c.isspace() for c in w) for w in words):
        raise ValueError("wrap.word")
    n = len(words)
    costs, ends = [0] * (n+1), [0] * n
    for i in range(n-1, -1, -1):
        used, best = 0, None
        for j in range(i, n):
            used += len(words[j]) + (j > i)
            if used > width:
                break
            cost = 0 if j == n-1 else (width-used)**2 + costs[j+1]
            if best is None or cost < best:
                best, ends[i] = cost, j+1
        costs[i] = best
    lines, i = [], 0
    while i < n:
        lines.append(" ".join(words[i:ends[i]]))
        i = ends[i]
    return lines
✳空白を含まない最大100語を1から80コードポイントの行へ分け、最終行以外の余白の二乗和を最小にします。
✓ 変更内容適用前に確認 ↗
ワークスペースのイメージ
AIコーディングワークスペース

次のアイデアはここから。

Windows版をダウンロード ↗