1.0.1 • Published 6 months ago

pdf-project-extractor v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

PDF Project Extractor

PDF dosyalarından proje bilgilerini otomatik olarak çıkaran bir TypeScript/Node.js paketi.

Özellikler

  • PDF dosyalarından metin çıkarma
  • Google Gemini AI API kullanarak akıllı metin analizi
  • TypeScript desteği
  • Next.js uyumlu
  • Yapılandırılmış JSON çıktısı
  • Aşağıdaki bilgileri otomatik olarak çıkarır:
    • Proje Adı
    • Proje Özet Tanımı
    • Yazar Bilgileri
    • Proje Başlangıç Tarihi
    • Projeye Başlanan/Geliştirilen Ülke
    • Ekip Üyesi Sayısı
    • Proje Kategorisi
    • Özellikler
    • Teknolojiler
    • Hedef Kitle
    • Uygulama Alanları
    • Zorluklar ve Çözümler
    • Faydalar
    • Linkler
    • Görseller

Kurulum

npm install pdf-project-extractor
# veya
yarn add pdf-project-extractor

Kullanım

Next.js API Route Örneği

// pages/api/analyze.ts
import { NextApiRequest, NextApiResponse } from 'next';
import { ProjectExtractor } from 'pdf-project-extractor';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  if (req.method !== 'POST') {
    return res.status(405).json({ error: 'Method not allowed' });
  }

  try {
    const extractor = new ProjectExtractor({
      apiKey: process.env.GEMINI_API_KEY!
    });

    // req.body.pdf içinde Buffer olarak PDF geldiğini varsayalım
    const result = await extractor.extractFromPDF(req.body.pdf);
    
    return res.status(200).json(result);
  } catch (error: any) {
    return res.status(500).json({ error: error.message });
  }
}

React/Next.js Component Örneği

// components/PDFAnalyzer.tsx
import { useState } from 'react';

export default function PDFAnalyzer() {
  const [result, setResult] = useState(null);
  const [loading, setLoading] = useState(false);

  const handleFileUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
    if (!event.target.files?.[0]) return;

    setLoading(true);
    const file = event.target.files[0];
    const formData = new FormData();
    formData.append('pdf', file);

    try {
      const response = await fetch('/api/analyze', {
        method: 'POST',
        body: formData
      });

      const data = await response.json();
      setResult(data);
    } catch (error) {
      console.error('Hata:', error);
    } finally {
      setLoading(false);
    }
  };

  return (
    <div>
      <input type="file" accept=".pdf" onChange={handleFileUpload} />
      {loading && <p>Yükleniyor...</p>}
      {result && (
        <div>
          <h2>{result.projectName}</h2>
          <p>{result.projectSummary}</p>
          {/* Diğer alanlar... */}
        </div>
      )}
    </div>
  );
}

Çıktı Tipi

interface ProjectResult {
  projectName: string | null;
  projectSummary: string;
  author: {
    name: string | null;
    title: string | null;
    organization: string | null;
  };
  startDate: string | null;
  country: string | null;
  teamSize: number | null;
  category: string | null;
  features: Array<{
    name: string;
    description: string;
    benefits: string[];
  }>;
  // ... diğer alanlar
}

Gereksinimler

  • Node.js 14 veya üzeri
  • Google Gemini API anahtarı

Lisans

MIT

1.0.1

6 months ago

1.0.0

6 months ago