# Sistema Profissional de Detecção de Plágio
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import numpy as np
from datetime import datetime
import json
import os
class
DetectorPlagioProfissional
:
def
__init__
(self, threshold=0.7, database_path="database.json"):
self.threshold = threshold
self.database_path = database_path
self.vectorizer = TfidfVectorizer(
ngram_range=(1, 5),
max_features=50000,
stop_words='english',
lowercase=True,
analyzer='word'
)
self.database = self.carregar_database()
def
carregar_database
(self):
"""Carrega base de dados existente"""
if
os.path.exists(self.database_path):
with
open(self.database_path, 'r', encoding='utf-8') as f:
return
json.load(f)
return
[]
def
salvar_database
(self):
"""Salva base de dados"""
with
open(self.database_path, 'w', encoding='utf-8') as f:
json.dump(self.database, f, ensure_ascii=False, indent=2)
def
adicionar_documento
(self, texto, titulo, autor, categoria="geral"):
"""Adiciona documento à base com metadados"""
documento = {
'id': len(self.database) + 1,
'texto': texto,
'titulo': titulo,
'autor': autor,
'categoria': categoria,
'data_adicao': datetime.now().isoformat(),
'palavras': len(texto.split())
}
self.database.append(documento)
self.salvar_database()
return
documento['id']