我正在使用omnicat-bayes
來分析文檔(文本分類)。有了這個寶石,我可以創建類別,並用文檔「提供」這些類別。目前這些類別有足夠的文件,以便能夠「足夠好地」識別應放置在哪個類別中的新文檔。帶有Omnicat-bayes文檔的文本分類預定義類別
現在在我的文檔控制器下創建操作是幾個步驟。
- 創建一個新的貝葉斯實例
- 創建將用於
- 以預文件訓練類別
- 的類別其實培訓的類別
(所有的那些步驟在run_all
函數下)
的創建操作:
def create
@document = Document.new(document_params)
@document.case_id = @case.id
if @document.save
run_all
# Running the classify function on reden aanmelding
classify_one = @bayes.classify(@document.reden_aanmelding)
document_category = classify_one.to_hash[:top_score_key]
# Updating the document category by the top key returned by Bayes
@document.update_attribute(:category, document_category)
finding_required_records
# Training Cees Buddy with the document that got saved
@bayes.train(document_category, @document.reden_aanmelding)
redirect_to case_path(@case)
else
render :new
end
end
裏面的@document.save
run_all功能(我知道這是不是真的最好的做法),我創建上面提到的四個步驟。
現在創建函數完成後,貝葉斯實例消失了,人工智能現在又變得「愚蠢」了。
我的問題是:什麼將一個合適的地方是,我怎麼能做到這一點,以創建新實例,新的類別和文件我的數據庫餵它們。 singleton
在這裏會有趣嗎?
感謝您的回答,我可以從此前進。我以前沒有想過多個流程部分,所以這非常有用。以及'dRuby'部分。我想我會試着將'omnicat-bayes'移到自己的微服務上。我認爲服務在獲取儘可能多的文檔時會更有價值,因此當它運行在自己的微服務上時,我可以將從多個應用程序提交的所有文檔傳輸到相同的服務。這也會導致對提交的文件更準確的分類。 –