コンテンツへスキップ
🛠️ToolsShed

テキスト要約

重要な文を抽出して長いテキストを要約します。

110

このツールについて

テキスト要約ツールは、長い文書や記事、レポートから最も重要な情報を素早く抽出し、キーとなる文を識別して保存します。研究論文を読むことが多い学生、複数の文書を管理する専門家、または何時間もかけずに情報を得たいという方にとって、欠かせないツールです。

テキスト入力フィールドにテキストを貼り付けるか入力し、要約の長さをニーズに合わせて調整するだけで、ツールが最も重要な文を知的に識別して簡潔な形で提示します。ブラウザ内で瞬時に動作し、アカウントや外部サーバーへのファイルアップロードが不要なため、日常的なテキスト圧縮の高速で安全なソリューションです。

このツールはニュース記事、学術論文、ビジネス文書など、重要な情報が明確に述べられている形式的でよく構成された内容に最も適しています。創作文やニッチな専門用語を含む高度に技術的な内容の場合は結果が異なる可能性があるため、要約が元のテキストの重要な詳細を見落としていないか、常に比較することをお勧めします。

よくある質問

コード実装

# Extractive text summarization (TF-based)
import re
from collections import Counter

STOP_WORDS = {
    "the", "a", "an", "and", "or", "but", "in", "on", "at", "to", "for",
    "of", "with", "by", "from", "is", "was", "are", "were", "be", "been",
    "has", "have", "had", "do", "does", "did", "will", "would", "could",
    "should", "that", "this", "it", "its", "he", "she", "they", "we", "you",
    "i", "not", "no", "as", "if", "so", "than", "then", "more", "most",
}

def tokenize_sentences(text: str) -> list[str]:
    sentences = re.split(r'(?<=[.!?])\s+', text.strip())
    return [s.strip() for s in sentences if len(s.strip()) > 10]

def word_frequency(sentences: list[str]) -> dict[str, int]:
    words = re.findall(r"[a-z']+", " ".join(sentences).lower())
    return Counter(w for w in words if w not in STOP_WORDS and len(w) > 2)

def score_sentences(sentences: list[str], freq: dict[str, int]) -> list[float]:
    scores = []
    n = len(sentences)
    for i, sentence in enumerate(sentences):
        words = re.findall(r"[a-z']+", sentence.lower())
        score = sum(freq.get(w, 0) for w in words)
        if words:
            score /= len(words)  # normalize by length
        # Position weight
        rel_pos = i / max(n - 1, 1)
        if rel_pos <= 0.2:
            score *= 1.4
        elif rel_pos >= 0.8:
            score *= 1.2
        scores.append(score)
    return scores

def summarize(text: str, num_sentences: int = 3) -> str:
    sentences = tokenize_sentences(text)
    if len(sentences) <= num_sentences:
        return text

    freq = word_frequency(sentences)
    scores = score_sentences(sentences, freq)

    # Get top-N sentence indices, sort by original position
    ranked = sorted(range(len(scores)), key=lambda i: -scores[i])[:num_sentences]
    selected = sorted(ranked)

    return " ".join(sentences[i] for i in selected)

# Example
text = """..."""  # Your long text here
print(summarize(text, num_sentences=3))

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.