|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
read sentences from a a-bit-long txt file
How can we read a text (let's say a story text, or smthng else ) and put it into a mysql db sentence by sentence, every single sentence will be a line in db.
|
|
#2
|
|||
|
|||
|
RE: read sentences from a a-bit-long txt file
|
|
#3
|
|||
|
|||
|
RE: read sentences from a a-bit-long txt file
I did this it does what I want but deletes dot and question marks at the and of sentence.
$data = file("text.txt"); $data = implode("n", $data); $data=preg_split ("/[.?]/" , $data, -1, PREG_SPLIT_DELIM_CAPTURE); how can I correct it not to delete dot |
|
#4
|
|||
|
|||
|
RE: read sentences from a a-bit-long txt file
You can make a preg_replace(".", ".<dot>", $data);
explode("<dot>", $data); |
|
#5
|
|||
|
|||
|
RE: read sentences from a a-bit-long txt file
I got this error :
No ending delimiter '.' found in ... and also another problem a sentence may end with ? or ! |
|
#6
|
|||
|
|||
|
RE: read sentences from a a-bit-long txt file
Can't test it right at this moment, but try:
preg_replace("'.'", ".<dot>", $data); I'm not an expert in regular expressions, but if you would like to split at ? and ! I think this will work: <? $search = array("'.'", "'?'", "'!'"); $replace = array(".<dot>", ".<dot>", ".<dot>"); preg_replace($search, $replace, $data); |
|
#7
|
|||
|
|||
|
RE: read sentences from a a-bit-long txt file
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > read sentences from a a-bit-long txt file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|