Results 1 to 13 of 13
-
13-06-2012, 12:01 PM #1
PHP Help me extract page number from text
The document is inserted as a text file in the database. the table structure is
id(number) Title(Text) Body(Long Text)
The body may be a 500 page book in text format.
The content in the text file is written (continuously) as
-(-p- 1 )-
content of page 1
-(-p- 2 )-
content of page 2
---so on
Now I need to store this data as individual page in another table automatically which has the following structure--
id ( may be FK from previous table)
content (page wise text content, automatically extracted)
page number( automatically extracted)
I am in total blank how to generate the second table from the first one. I am using PHP 5 with Mysql 5 and Apache 2.2.
Any suggestion is gracefully accepted.
P.S-- The actual page numbers are unicode non-english numbers which are unique and never repeated inside the body of the text.Desktop: P-IV 2.4GHz, 512MB DDR, 865GBF Mother Board,
G-Force 5200FX, 17" Samsung flat, WinXp with SP2,
Kaspersky Internet Security 2012.
Laptop:LENOVO 3000 C100 D7 lappy with 2GB DDR2.
-
13-06-2012, 01:46 PM #2
Re: PHP Help me extract page number from text
maybe have a look at querypath OR preg_match OR simple_html_dom ?
I think, but am not sure, that using preg_match would solve your issue. Check its manual page and report back if you need more help..Discountghar.in - Several Discounts from flipkart.com in one place
Search Indian tech bazaar forums. Its back online!
Computer parts search Engine(for india) : http://goo.gl/Sg8Yv
-
13-06-2012, 11:12 PM #3
Re: PHP Help me extract page number from text
I have to extract the text between the two page numbers and assign the smaller page number (between the two) to the extracted page and insert them to the table immediately. This process continues until the end of the file is reached. I cannot use a counter to generate page number as the book contains index pages and references also which does not have any page number.
P.S- I think querypath cannot be used with plain text, it can be used only with html or XML. Not sure though.Last edited by bukaida; 13-06-2012 at 11:24 PM. Reason: Remember more later
Desktop: P-IV 2.4GHz, 512MB DDR, 865GBF Mother Board,
G-Force 5200FX, 17" Samsung flat, WinXp with SP2,
Kaspersky Internet Security 2012.
Laptop:LENOVO 3000 C100 D7 lappy with 2GB DDR2.
-
13-06-2012, 11:24 PM #4
Re: PHP Help me extract page number from text
hmm
then maybe you could look for double/triple linebreaks or something. Just thinking... Its difficult for me to say conclusively without seeing a sample of the data.Discountghar.in - Several Discounts from flipkart.com in one place
Search Indian tech bazaar forums. Its back online!
Computer parts search Engine(for india) : http://goo.gl/Sg8Yv
-
14-06-2012, 11:20 AM #5
Re: PHP Help me extract page number from text
Use
PHP Code:$pages = preg_split('/-(-p- \d+ )-/', $body);
foreach($pages as $i=>$p)
echo "Page no: $i", "Body: $p";
AMD Phenom II X6 1055T|MSI 880GMA-E45|MSI 7770|2x2 Corsair DDR3 1333MHz|CM Elite 310|Corsair CX400W|DELL ST2320L
Myself @ nbaztec.co.in
Build Your Rig! (XBlade) @ nbaztec.co.in - Build Your Rig!
My Inner Artist @ nbaztec.co.in - Designs
-
14-06-2012, 05:45 PM #6
Re: PHP Help me extract page number from text
^
@nbaztec you need to escape '(' and '-' characters.
sobecomesPHP Code:/-(-p- \d+ )-/
PHP Code:/\-\(\-p\- \d+ \)\-/
Last edited by khmadhu; 14-06-2012 at 05:46 PM. Reason: added PHP tag
If you really wanna think, try to think from Atom to Universe!!
cpu: core i5 2500k, mobo: DP67BG, RAM:Corsair 8GB(4x2) 1600 Mhz, XFX HD 5770, 1TB seagate 6Gbps 7200 rpm , SAGA II 500W
-
14-06-2012, 06:02 PM #7
Re: PHP Help me extract page number from text
AMD Phenom II X6 1055T|MSI 880GMA-E45|MSI 7770|2x2 Corsair DDR3 1333MHz|CM Elite 310|Corsair CX400W|DELL ST2320L
Myself @ nbaztec.co.in
Build Your Rig! (XBlade) @ nbaztec.co.in - Build Your Rig!
My Inner Artist @ nbaztec.co.in - Designs
-
15-06-2012, 01:49 PM #8
Re: PHP Help me extract page number from text
I thought '-' may interfere with range symbol, I think it depends on regex engine!.
If you really wanna think, try to think from Atom to Universe!!
cpu: core i5 2500k, mobo: DP67BG, RAM:Corsair 8GB(4x2) 1600 Mhz, XFX HD 5770, 1TB seagate 6Gbps 7200 rpm , SAGA II 500W
-
15-06-2012, 04:51 PM #9
Re: PHP Help me extract page number from text
No, '-' has meaning only inside character classes. It's valid across all common regex engines.
AMD Phenom II X6 1055T|MSI 880GMA-E45|MSI 7770|2x2 Corsair DDR3 1333MHz|CM Elite 310|Corsair CX400W|DELL ST2320L
Myself @ nbaztec.co.in
Build Your Rig! (XBlade) @ nbaztec.co.in - Build Your Rig!
My Inner Artist @ nbaztec.co.in - Designs
-
16-06-2012, 10:54 AM #10
Re: PHP Help me extract page number from text
Ok guys, here is the sample data
Donot bother much about the content ( A text in bengali from tagore, you can copy-paste to google translate if you are really interestedCode:-(-পৃ- ৩৭৮ )- গোরা -(-পৃ- ৩৭৯)- ১ শ্রাবণ মাসের সকালবেলায় মেঘ কাটিয়া গিয়া নির্মল রৌদ্রে কলিকাতার আকাশ ভরিয়া গিয়াছে। রাস্তায় গাড়িঘোড়ার বিরাম নাই, ফেরিওয়ালা অবিশ্রাম হাঁকিয়া চলিয়াছে, যাহারা আপিসে কালেজে আদালতে যাইবে তাহাদের জন্য বাসায় বাসায় মাছ-তরকারির চুপড়ি আসিয়াছে ও রান্নাঘরে উনান জ্বালাইবার ধোঁওয়া উঠিয়াছে কিন্তু তবু এত বড়ো এই-যে কাজের শহর কঠিনহৃদয় কলিকাতা, ইহার শত শত রাস্তা এবং গলির ভিতরে সোনার আলোকের ধারা আজ যেন একটা অপূর্ব যৌবনের প্রবাহ বহিয়া লইয়া চলিয়াছে। এমন দিনে বিনা-কাজের অবকাশে বিনয়ভূষণ তাহার বাসার দোতলার বারান্দায় একলা দাঁড়াইয়া রাস্তায় জনতার চলাচল দেখিতেছিল। কালেজের পড়াও অনেক দিন চুকিয়া গেছে, অথচ সংসারের মধ্যেও প্রবেশ করে নাই, বিনয়ের অবস্থাটা এইরূপ। সভাসমিতি চালানো এবং খবরের কাগজ লেখায় মন দিয়াছে— কিন্তু তাহাতে সব মনটা ভরিয়া উঠে নাই। অন্তত আজ সকালবেলায় কী করিবে তাহা ভাবিয়া না পাইয়া তাহার মনটা চঞ্চল হইয়া উঠিতেছিল। পাশের বাড়ির ছাতের উপরে গোটা-তিনেক কাক কী লইয়া ডাকাডাকি করিতেছিল এবং চড়ুই-দম্পতি তাহার বারান্দার এক কোণে বাসা-নির্মাণ-ব্যাপারে পরস্পরকে কিচিমিচি শব্দে উত্সাহ দিতেছিল— সেই-সমস্ত অব্যক্ত কাকলি বিনয়ের ইচ্ছা করিতে লাগিল বাউলকে ডাকিয়া এই অচিন পাখির গানটা লিখিয়া লয়, কিন্তু ভোর-রাত্রে যেমন শীত-শীত করে অথচ গায়ের কাপড়টা টানিয়া লইতে উদ্যম থাকে না, তেমনি একটা আলস্যের ভাবে বাউলকে ডাকা হইল না, গান লেখাও হইল না, কেবল ঐ অচেনা পাখির সুরটা মনের মধ্যে গুন্* গুন্* করিতে লাগিল। বিনয় তাঁহাকে ধরাধরি করিয়া নামাইয়া দিল, এবং তাঁহার মুখ বিবর্ণ হইয়া গেছে দেখিয়া জিজ্ঞাসা করিল, “আপনার লাগে নি তো?” তিনি “না, কিছু হয় নি” বলিয়া হাসিবার চেষ্টা করিলেন, সে হাসি তখনই মিলাইয়া গেল এবং তিনি মূর্ছিত হইয়া পড়িবার উপক্রম করিলেন। বিনয় তাঁহাকে ধরিয়া ফেলিল ও উত্কণ্ঠিত মেয়েটিকে কহিল, “এই সামনেই আমার বাড়ি ; ভিতরে চলুন।” বৃদ্ধকে বিছানায় শোওয়ানো হইলে মেয়েটি চারি দিকে তাকাইয়া দেখিল ঘরের কোণে একটি জলের কুঁজা আছে। তখনই সেই কুঁজার জল গেলাসে করিয়া লইয়া বৃদ্ধের মুখে ছিটা দিয়া বাতাস -(-পৃ- ৩৮০)-
)
The interesting terms are -(-পৃ- ৩৭৮ )- and -(-পৃ- ৩৭৯)- from where only the ৩৭৮ and ৩৭৯ are page numbers. The aim is to extract the content between this two and assign ৩৭৮ to it since it appeared earlier ( cannot do comparison to find the smaller directly, I think).Desktop: P-IV 2.4GHz, 512MB DDR, 865GBF Mother Board,
G-Force 5200FX, 17" Samsung flat, WinXp with SP2,
Kaspersky Internet Security 2012.
Laptop:LENOVO 3000 C100 D7 lappy with 2GB DDR2.
-
16-06-2012, 11:51 AM #11
Re: PHP Help me extract page number from text
The thing is regex engines don't support UTF-8. But they support Unicode. So you'll have to form the regex manually while knowing the unicode codes for the characters.
For eg:
The regex can be used to split on those lines and also to obtain the page numbers. Alternatively the indexes of the pages are themselves page numbers.PHP Code:$pages = preg_split('/-\s*\(\s*-\s*\x{09aa}\x{09c3}\s*-\s*([\x{09e6}-\x{09ef}]+)\s*\)-\)-/u', $s));
AMD Phenom II X6 1055T|MSI 880GMA-E45|MSI 7770|2x2 Corsair DDR3 1333MHz|CM Elite 310|Corsair CX400W|DELL ST2320L
Myself @ nbaztec.co.in
Build Your Rig! (XBlade) @ nbaztec.co.in - Build Your Rig!
My Inner Artist @ nbaztec.co.in - Designs
-
17-06-2012, 02:17 PM #12
Re: PHP Help me extract page number from text
Desktop: P-IV 2.4GHz, 512MB DDR, 865GBF Mother Board,
G-Force 5200FX, 17" Samsung flat, WinXp with SP2,
Kaspersky Internet Security 2012.
Laptop:LENOVO 3000 C100 D7 lappy with 2GB DDR2.
-
17-06-2012, 02:40 PM #13
Re: PHP Help me extract page number from text
AMD Phenom II X6 1055T|MSI 880GMA-E45|MSI 7770|2x2 Corsair DDR3 1333MHz|CM Elite 310|Corsair CX400W|DELL ST2320L
Myself @ nbaztec.co.in
Build Your Rig! (XBlade) @ nbaztec.co.in - Build Your Rig!
My Inner Artist @ nbaztec.co.in - Designs
Similar Threads
-
pass a text information to a php page using link
By bukaida in forum ProgrammingReplies: 4Last Post: 27-05-2008, 11:55 AM -
How to convet scanned page. into text format
By Kaushal Hiwarkar in forum QnA (read only)Replies: 3Last Post: 22-10-2007, 03:23 PM -
MS Word Auto Page Number Problem
By khandu in forum Software Q&AReplies: 1Last Post: 30-03-2007, 12:46 AM -
IS it possible to extract text from BMP/JPEG image..?
By mkmkmk in forum QnA (read only)Replies: 10Last Post: 31-05-2006, 07:10 PM -
printed page back to text file...?
By Saharika in forum QnA (read only)Replies: 2Last Post: 13-11-2005, 06:16 PM



LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks