Hii ijust want to ask that how can i convert a image to text using OCR ?
if(isset($_FILES['image'])){
$file_name = $_FILES['image']['name'];
$file_tmp =$_FILES['image']['tmp_name'];
move_uploaded_file($file_tmp,"image/".$file_name);
echo "<h3>Image Upload Success</h3>";
echo '<img src="'.$file_name.'" style="width:70%">';
shell_exec('"C:\\Program Files\\Tesseract-OCR\\tesseract" "D:\\xampp\\htdocs\\ci3\\image\\'.$file_name.'" out');
echo "<br><h3>OCR after reading</h3><br><pre>";
$myfile = fopen("out.txt", "r") or die("Unable to open file!");
echo fread($myfile,4045);
fclose($myfile);
echo "</pre>";
}
I just write this code but it is like not convert the image text properly so is their any solution so please let me know !!
I Expecting that its work i vertical image to read the text but in my output it read like.........
The Registration Directorate at the Ministry of Industry, Commerce and Tourism
certifies that the merchant's below details have been registered in accordance with
Decree law No. (27) for the year 2015 of the Commercial Registration.
22/04/2023 GliaiuY! ~,6 Registration 22/04/2007
Date
eroup HORIZON TELECOM SERVICES COMPANY WLL
Name
Commercial
Name
Registration
Type
CR
Status
HORIZON TELECOM SERVICES COMPANY WLL
With Limited Liability Company
ACTIVE
Area 4élaicl!
ABU SAYBA/ a2 5!
P.O.BOX #.ye Road & »b
7325
Block asx
473
Commercial
Address
Activities
Sale and installation of telecommunications equipment and parts
ere! Bylo!
Registration Directorate
QF. 409 Issue 0
* This CR does not permit its holder to practice investment activities on behalf of others.
igiwltzads
(alka,
KINGDOM OF BAHRAIN pues.
Ministry of Industry, ©
Commerce and Tourism R
Solenitl J) 15 bol gd
Commercial Registration Certificate
ell ad oi hath dala yb yleill s Ae licall 8 51} 52 apsaill 6 pla) agts
GSM Dasa GLE; 2015 Aid (27) aby cy silds p pes pall Cady alld g oLisi atltly Aba uell
Judll 6 Registration == 4908 - 1
aad CYL) Glesal 6 5 jl st 4S 8 Ac gore! pul
aed VLA) Las) Oy jolt ASS ole usd
Ba gdare Aud gious IS AS ph andl ¢ 93
dads aud Le
Flat/Shop No. J=«/4a4
11
Building +
608 Gola ol gual
Woke abby SYLSIYI Glace af jlo
wsdl Ul gal pletion! LU 49) jo: 4ualial jin Y all lhe *
Issued Date: 20/04/2022 Page 1 of 1
}
Z/
Please post this certificate at a visible place.
Tel: +973 80001700 - www. sijilat.bh - www.moic.gov.bh
boat! S12 Sol GIS Bolg S! che 5 oe
but i need a seprate column to read a proper text formate
I'm trying to build an efficient autocomplete search for my Spring boot app, but I'm not getting the proper results.
I have a cars database with multiple car models.
This is my current search aggregation
val agg = Document(
"\$search", Document(
"compound", Document(
"must", searchInput.split(" ").map {
Document(
"autocomplete", Document("query", it)
.append("path", "fullName")
)
}
)
)
)
fullName represents the full name of the car: Brand + Model + Year + Power
The search works but not good enough yet.
For instance if I search for "Ford GT" first results that come up are:
Ford Mustang GT V8 5.0
Ford Mustang GT 390 Fastback
Ford Mustang GT 302 HO
and so on.
But the first results should be:
Ford GT - 655 PS
Ford GT40 Mk III
and only afterwards, the ones above.
How can I achieve this?
So this example would be for any interactive dashboard like Kibana or PowerBI.
So say I have a vehicle 556 in a fleet of vehicles.
at 08:41:50 said vehicle generates an alarm (Engine overheated)
2021-04-21T08:41:50 Priority 2 alarm - Vehicle 556 - Engine overheating
I would like to then be able to click on this alarm, and get a dashboard which would show me known states from the vehicle at the time of the event.
e.g. speed of vehicle, accelaration percentage, braking percentage, and off course data which would come from other datasources, like weather information, driver etc.
So from the dashboard, I would expect based on below logs to see the following:
Vehicle: 556
Datetime: 2021-04-21 08:41:50
Speed: 42mph
Accelaration: 70%
Braking: 65%
Weather: Sunny, 80 deg
Other alarms: Engine fan stalled
2021-04-21T06:35:50 info - Weather - Sunny 75 deg
2021-04-21T07:35:50 info - Weather - Sunny 78 deg
2021-04-21T08:34:23 Priority 1 alarm - Vehicle 556 - Engine fan stalled
2021-04-21T08:35:50 info - Weather - Sunny 80 deg
2021-04-21T08:41:38 info - Vehicle 556 - Acceleration: 100%
2021-04-21T08:41:38 info - Vehicle 556 - Braking: 40%
2021-04-21T08:41:38 info - Vehicle 556 - Speed 24 mph
2021-04-21T08:41:42 info - Vehicle 556 - Acceleration: 97%
2021-04-21T08:41:42 info - Vehicle 556 - Braking: 50%
2021-04-21T08:41:42 info - Vehicle 556 - Speed 38 mph
2021-04-21T08:41:45 info - Vehicle 556 - Acceleration: 70%
2021-04-21T08:41:45 info - Vehicle 556 - Braking: 65%
2021-04-21T08:41:45 info - Vehicle 556 - Speed 42 mph
2021-04-21T08:41:50 Priority 2 alarm - Vehicle 556 - Engine overheating
For "bonus points" being able to then click the last known speed, and see a log which shows the last e.g. 10 logs regarding vehicle speed would also be nice.
But is this a thing in any database or specifically powerbi or elasticsearch/kibana
or would this require a custom created application-dashboard.
or is it indeed just because I don't know the right search term
For Power BI, there's a useful function LASTNONBLANKVALUE which can handle this. The best documentation source (DAX Guide) for this is below, it includes the product documentation plus a live sandpit:
https://dax.guide/lastnonblankvalue/
For your scenario, I imagine using the timestamp for the 1st parameter (ColumnName), then the 3rd segment of the log text (e.g. a derived column with values like "Speed 42 mph") for the 2nd parameter.
I would build a set of DAX columns to prepare the data, using CALCULATE to restrict the set of rows considered. DAX Measures might be more flexible and dynamic, but are much more abstract to develop and query performance can suffer if they are complex.
Here's an example to get the Last Speed for each non-info Log row. I assume some data transformation to get helper columns for Vehicle etc.
Last Speed =
VAR v_Timestamp_Max = LogTable[Timestamp]
VAR v_Vehicle = LogTable[Vehicle]
RETURN
IF ( LogTable[Level] <> "info" ,
CALCULATE (
LASTNONBLANKVALUE ( LogTable[Timestamp], MAX ( LogTable[Value] ) ),
ALL ( LogTable ),
LogTable[Timestamp] < v_Timestamp_Max,
LogTable[Vehicle] = v_Vehicle,
LogTable[Value Type] = "Speed"
)
)
I have multiple csv files in S3, I want to merge those files into one with removal of duplicates based on columns.
file1:
Date ID Name Count Price
2019-08-25 110146 Amazon In-App 1 23
2019-08-25 121615 Google US Rally 0 0
2019-08-25 208442 Google Rewarded US 47 12
2019-08-26 110146 Amazon In-App 10 40
2019-08-26 121615 Google US Rally 0 0
2019-08-26 208442 Google Rewarded US 0 0
file2:
Date ID Name Count Price
2019-08-26 110146 Amazon In-App 30 90
2019-08-26 121615 Google US Rally 5 25
2019-08-26 208442 Google Rewarded US 15 45
2019-08-27 110146 Amazon In-App 5 15
2019-08-27 121615 Google US Rally 10 40
2019-08-27 208442 Google Rewarded US 0 0
file3:
Date ID Name Count Price
2019-08-27 110146 Amazon In-App 30 70
2019-08-27 121615 Google US Rally 12 50
2019-08-27 208442 Google Rewarded US 15 45
2019-08-28 110146 Amazon In-App 15 55
2019-08-28 121615 Google US Rally 20 60
2019-08-28 208442 Google Rewarded US 0 0
Below are the sample files. I want to merge the above files with unique columns such as ID and Name.
My Expected Output:
final_output_file:
Date ID Name Count Price
2019-08-25 110146 Amazon In-App 1 23
2019-08-25 121615 Google US Rally 0 0
2019-08-25 208442 Google Rewarded US 47 12
2019-08-26 110146 Amazon In-App 30 90
2019-08-26 121615 Google US Rally 5 25
2019-08-26 208442 Google Rewarded US 15 45
2019-08-27 110146 Amazon In-App 30 70
2019-08-27 121615 Google US Rally 12 50
2019-08-27 208442 Google Rewarded US 15 45
2019-08-28 110146 Amazon In-App 15 55
2019-08-28 121615 Google US Rally 20 60
2019-08-28 208442 Google Rewarded US 0 0
How to achieve it using ruby?
I have tried the following approach and matches all columns and it doesn't satisfy my need.
require 'set'
unique = Set.new
Dir.glob('revenue_report_*.csv') do |f|
File.foreach(f) { |l| unique << l }
end
File.write('unique.csv', unique.sort.join)
Code
require 'csv'
def doit(*csv_input_files, csv_output_file)
CSV.open(csv_output_file, "wb", headers: true) do |csv_out|
csv_out << CSV.open(csv_input_files.first, &:readline)
csv_input_files.each_with_object({}) do |f,h|
CSV.read(f, headers: true).each do |csv|
h[[csv['Date'], csv['ID']]] = csv
end
end.values.each { |row| csv_out << row }
end
end
Example
F1 = 'f1.csv'
F2 = 'f2.csv'
F3 = 'f3.csv'
File.write(F1, <<~END)
Date,ID,Name,Count,Price
2019-08-25,110146,Amazon In-App,1,23
2019-08-25,121615,Google US Rally,0,0
2019-08-25,208442,Google Rewarded US,47,12
2019-08-26,110146,Amazon In-App,10,40
2019-08-26,121615,Google US Rally,0,0
2019-08-26,208442,Google Rewarded US,0,0
END
#=> 260
File.write(F2, <<~END)
Date,ID,Name,Count,Price
2019-08-26,110146,Amazon In-App,30,90
2019-08-26,121615,Google US Rally,5,25
2019-08-26,208442,Google Rewarded US,15,45
2019-08-27,110146,Amazon In-App,5,15
2019-08-27,121615,Google US Rally,10,40
2019-08-27,208442,Google Rewarded US,0,0
END
#=> 263
File.write(F3, <<~END)
Date,ID,Name,Count,Price
2019-08-27,110146,Amazon In-App,30,70
2019-08-27,121615,Google US Rally,12,50
2019-08-27,208442,Google Rewarded US,15,45
2019-08-28,110146,Amazon In-App,15,55
2019-08-28,121615,Google US Rally,20,60
2019-08-28,208442,Google Rewarded US,0,0
END
#=> 265
Fout = 'fout.csv'
doit(F1, F2, F3, Fout)
puts File.read(Fout)
Date,ID,Name,Count,Price
2019-08-25,110146,Amazon In-App,1,23
2019-08-25,121615,Google US Rally,0,0
2019-08-25,208442,Google Rewarded US,47,12
2019-08-26,110146,Amazon In-App,30,90
2019-08-26,121615,Google US Rally,5,25
2019-08-26,208442,Google Rewarded US,15,45
2019-08-27,110146,Amazon In-App,30,70
2019-08-27,121615,Google US Rally,12,50
2019-08-27,208442,Google Rewarded US,15,45
2019-08-28,110146,Amazon In-App,15,55
2019-08-28,121615,Google US Rally,20,60
2019-08-28,208442,Google Rewarded US,0,0
See CSV::open, CSV::read, File::new, IO#gets and Hash#values. This article on working with CSV files may be of interest.
I have a variable address which for now is a long string containing some unneccessary info, eg: "Aboriginal Relations 11th Floor Commerce Place 10155 102 Street Edmonton AB T5J 4G8 Phone 780 427-9658 Fax 780 644-4939 Email gerry.kushlyk#gov.ab.ca"
Aboriginal Relations is in a variable called title, and I'm trying to call address.gsub!(title,''), but its returning the original string.
I've also tried address.gsub!(/#{title}/,'') and address.gsub!("#{title}",'') but those won't work either. Any ideas?
Sorry, the typo occurred when I typed it into stack overflow, heres the code and the output, copied and pasted:
(this is within a loop, so there will be multiple outputs)
p title
address.gsub!(title,'')
p address
output
"Aboriginal Relations "
"Aboriginal Relations 11th Floor Commerce Place 10155 102 Street Edmonton AB T5J 4G8 Phone 780 427-9658 Fax 780 644-4939 Email gerry.kushlyk#gov.ab.ca"
"Aboriginal Tourism Advisory Council "
"Aboriginal Tourism Advisory Council 5th Floor Terrace Building 9515 107 Street Edmonton AB T5K 2C3 Phone 780 427-9687 Fax 780 422-7235 Email foip.fintprccs#gov.ab.ca"
"Acadia Foundation "
"Acadia Foundation PO Box 96 Oyen AB T0J 2J0 Phone 403 664-3384 Fax 403 664-3316 Email acadiafoundation#telus.net"
"Access Advisory Council "
"Access Advisory Council 12th Floor Centre West Building 10035 108 Street Edmonton AB T5J 3E1 Phone 780 427-2805 Fax 780 422-3204 Email barb.joyner#gov.ab.ca"
"ACCM Benevolent Association "
"ACCM Benevolent Association Suite 100 9403 95 Avenue Edmonton AB T6C 4M7 Phone 780 468-4648 Fax 780 468-4648 Email accmmanor#shaw.ca"
"Acme Municipal Library "
"Acme Municipal Library PO Box 326 Acme AB T0M 0A0 Phone 403 546-3845 Fax 403 546-2248 Email aamlibrary#marigold.ab.ca"
likewise, if I try address.match(/#{title}/) I get nil.
I'm assuming you're using ruby 1.9 or higher.
It's possible that the trailing whitespace is a non-breaking space:
p "Relations\u00a0" # looks like a trailing space, but strip won't remove it
to get rid of it:
"Relations\u00a0".gsub!(/^\u00a0|\u00a0$/, '') # => "Relations"
A more generic solution for all unicode whitespace:
"Relations\u00a0".gsub!(/^[[:space:]]|[[:space:]]$/, '') # => "Relations"
To see what the character is in your case:
title[-1].ord # => 160 (example only)
'%x' % title[-1].ord # => "a0" (hex equivalent; example only)
title = title[0..-2] seemed to solve it. for some reason strip and chomp wouldn't work.