Document Classificationのロゴ

Document Classification

コミュニティ
Ruinius
Document Classification

Classify financial PDFs by extracting company identity, document type, and date metadata. Validates ticker via Yahoo Finance with multi-step fallback. Uses a Python orchestration script for validation, file modification, and writing markdown.

概要

公開者Ruinius
リポジトリfinancial-analyst-skills
スキル名Document Classification
スター
5
フォーク
1
同梱ファイル
6
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 6個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    RuiniusがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Document Classification」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Ruinius/financial-analyst-skills/tree/main/skills/document_classification
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Ruinius/financial-analyst-skills.git /tmp/financial-analyst-skills
mkdir -p .claude/skills
cp -r /tmp/financial-analyst-skills/skills/document_classification .claude/skills/ruinius-document-classification
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでDocument Classificationを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にDocument Classificationを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Document Classificationは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Document Classification Skill

This skill takes a PDF from input_data/, classifies it, abstracts metadata, and uses an orchestration script to validate the company ticker and produce a standardized markdown file in processing_data/.

Prerequisites

  • Python 3.10+
  • PDFs placed in input_data/ directory at the project root
  • If a static file server is not running on localhost:8181 then ask the user to run .\tools\start_file_server.bat

DO NOT EVER start servers without human user.

Inputs

  • One or more PDF files in input_data/

Outputs

  • Renamed PDF in processing_data/: TICKER_DOCTYPE_YYYYMMDD_temp.pdf
  • Markdown file in processing_data/: TICKER_DOCTYPE_YYYYMMDD_temp.md

Step-by-Step Instructions

Batch Mode: Repeat Steps 1–6 for EVERY .pdf file in input_data/. Track which files have been processed and continue until all are done. Report a summary at the end.

Step 1: Pick the Next PDF to Process

  1. List all .pdf files in input_data/
  2. If no PDFs exist (or all have already been processed), stop and inform the user: "No PDFs found in input_data/" or "All PDFs processed."
  3. Pick the next unprocessed PDF in input_data/. Keep track of its filename.
  4. Continue to Step 2 for this PDF.

Step 2: Read the PDF

  1. Ensure a background process running the file server is active (.\tools\start_file_server.bat).
  2. Open the PDF in the browser using the browser_subagent tool:
    • Navigate to the PDF via the local server, e.g., http://localhost:8181/input_data/{filename}
    • The browser renders PDFs natively with full visual fidelity
  3. Read the first 1–3 pages to extract classification metadata (company name, ticker, document type, dates)
  4. For large documents (10-K, 10-Q, analyst reports), you do NOT need to read every page — focus on the cover page and table of contents
  5. Do NOT use PyPDF2 or other text extraction libraries — the browser approach preserves table layouts and handles scanned/image-based documents
  6. If the PDF cannot be opened in the browser, stop and inform the user

Step 3: Classify the Document

From the PDF content read in Step 2, extract the following fields. Refer to skills/document_classification/resources/document_types.json for validation and exact naming of Document Types.

Fields to extract:

FieldFormatDescription
document_typestringMUST strictly be one of the keys in document_types.json
company_namestring or nullCompany name as found in the document
tickerstring or nullStock ticker symbol (uppercase, 1-5 chars)
confidencestringOne of: high, medium, low

Anti-hallucination rules:

  • ONLY extract information EXPLICITLY shown in the document text
  • DO NOT invent, infer, or assume company names, tickers, or dates
  • If information is not visible, use null
  • DO NOT use external knowledge to fill in missing information at this step

Step 4: Extract Dates

Extract each date field carefully, paying close attention to the document context.

Fiscal Year Awareness: Before assigning time_period, check skills/document_classification/resources/fiscal_year_map.json to see if this company has a non-standard fiscal year. Many retail and tech companies (e.g., LULU, WMT, COST, NKE, BABA) have fiscal years ending in months other than December. This shifts which calendar months map to which fiscal quarters.

  • If the ticker IS in the map, use the fiscal_year_ends entry to determine the correct fiscal quarter from the period_end_date.
  • If the ticker is NOT in the map, assume a standard calendar fiscal year (ending December 31).
4a: Extract document_date
  • The date the document was published or released
  • Format: YYYY-MM-DD
4b: Extract time_period
  • The fiscal reporting period
  • Format: Q1 YYYY, Q2 YYYY, Q3 YYYY, Q4 YYYY, or FY YYYY
  • Important: Use the company's fiscal calendar, not the calendar year. For example, LULU's fiscal year ends in January, so a period ending Jan 28, 2024 is Q4 FY2023, not Q1 2024.
4c: Extract period_end_date
  • The date the financial period ended (quarter end or fiscal year end)
  • Format: YYYY-MM-DD

Step 5: Execute Orchestration Script

Run the python orchestration script to validate and finalize the classification. This script will automatically validate the ticker against Yahoo Finance, rename strings according to document type abbreviations, move the file, and create the final markdown file.

Execute the following terminal command with the correctly formatted strings from Steps 3 and 4:

bash
uv run python skills\document_classification\scripts\process_classification.py --filename "FILENAME.pdf" --company_name "Extracted Company Name" --ticker "TICKER" --document_type "document_type" --document_date "YYYY-MM-DD" --time_period "time_period" --period_end_date "YYYY-MM-DD" --confidence "high"

If it succeeds, output the success to the user. If there are more PDFs remaining in input_data/, return to Step 1 for the next file. Otherwise, print a final summary of all processed documents and finish the run.

💡 First-File Scenario: If the document is the first one being processed for a ticker (no output_data/TICKER exists), Phase 5 (Qualitative Assessment) will require you to manually initialize the ticker directory and TICKER_metadata.md file.

Step 6: Reflection — Use LLM Knowledge (Fallback)

If the script in Step 5 throws an error (e.g. invalid ticker):

  1. Ask the LLM: "Given this company name and document context, what is the correct stock ticker?"
  2. The LLM IS allowed to use its knowledge here (unlike Step 3)
  3. If a new ticker is found, re-run Step 5 with the new ticker.
  4. If it still fails, ask the human user for the correct ticker.

Error Handling

  • If PDF cannot be opened in the browser → Inform user, skip this PDF
  • If classification fails → Retry once, then inform user
  • If ticker validation completely fails → Ask human user for the correct ticker
  • If date extraction fails → Set failed fields to null, proceed with available data

Changelog

  • 2026-05-06: Updated example command to use uv run per project standards. Added note about first-file initialization for qualitative documents.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Document Classification」では何ができますか?

Classify financial PDFs by extracting company identity, document type, and date metadata. Validates ticker via Yahoo Finance with multi-step fallback. Uses a Python orchestration script for validation, file modification, and writing markdown.

TypingMindでDocument Classificationを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Document Classificationはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにDocument Classificationをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Ruinius/financial-analyst-skills/tree/main/skills/document_classificationを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Document Classificationを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Document Classificationで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもDocument Classificationを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Document Classification」は無料ですか?

はい。RuiniusがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇