Skip to content

Commit

Permalink
ocr class
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Dec 16, 2024
1 parent 972f057 commit 4376d60
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/apis/ali_ocr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ def ocr_template(file, task_id:)
end
end

def ocr_class(file, class_id:)
body = {
action: 'PredictClassifierModel'
}
body.merge! opts: {
method: 'POST',
timeout: 15000
}
body.merge! params: {
ClassifierId: class_id,
Body: file,
BinaryToText: true
}

r = client.request(**body)
r.dig('Data', 'data').each_with_object({}) do |i, h|
h.merge! i['fieldName'] => i['fieldWordRaw']
end
end

def ocr_223(file, class_id: 223)
body = {
action: 'PredictClassifierModel'
Expand Down

0 comments on commit 4376d60

Please sign in to comment.