Created
October 24, 2015 19:01
-
-
Save iegik/fbc0b1268154371d0ec2 to your computer and use it in GitHub Desktop.
Сокращает текст до легко распозноваемого и читаемого
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div style="width:550px"> | |
| <form method="POST"> | |
| <textarea name="text" style="width:100%" rows="20" placeholder="Сокращает текст до легко распозноваемого и читаемого." onclick="this.value="<?=(@$_POST['text'])?$_POST['text']:'ddd'?>"><?=(@$_POST['text'])?$_POST['text']:''?></textarea> | |
| <input type="submit"/> | |
| </form> | |
| </div> | |
| <pre> | |
| <?php | |
| $sokr = array( | |
| '/а(\.|\s+)/', | |
| '/ащ(\.|\s+)/', | |
| '/ий(\.|\s+)/', | |
| '/ск(\.|\s+)/', | |
| '/ав(\.|\s+)/', | |
| '/ад(\.|\s+)/', | |
| '/аж(\.|\s+)/', | |
| '/аз(\.|\s+)/', | |
| '/ай(\.|\s+)/', | |
| '/аль(\.|\s+)/', | |
| '/ан(\.|\s+)/', | |
| '/ар(\.|\s+)/', | |
| '/ат(\.|\s+)/', | |
| '/аф(\.|\s+)/',// | |
| '/аю(\.|\s+)/', | |
| '/ей(\.|\s+)/', | |
| '/ел(\.|\s+)/', | |
| // '/ен(\.|\s+)/', | |
| '/ет(\.|\s+)/', | |
| '/ент(\.|\s+)/', | |
| // '/ер(\.|\s+)/', | |
| '/е(\.|\s+)/', | |
| '/и(\.|\s+)/', | |
| '/ил(\.|\s+)/', | |
| '/ин(\.|\s+)/', | |
| '/ион(\.|\s+)/', | |
| '/ир(\.|\s+)/', | |
| '/ит(\.|\s+)/', | |
| '/ич(\.|\s+)/', | |
| '/й(\.|\s+)/', | |
| // '/к(\.|\s+)/', | |
| '/ик(\.|\s+)/', | |
| '/н(\.|\s+)/', | |
| '/лен(\.|\s+)/', | |
| '/ны(\.|\s+)/', | |
| '/о(\.|\s+)/', | |
| '/ов(\.|\s+)/', | |
| '/ово(\.|\s+)/', | |
| '/овл(\.|\s+)/', | |
| '/ог(\.|\s+)/', | |
| // '/од(\.|\s+)/', | |
| '/оль(\.|\s+)/', | |
| '/ом(\.|\s+)/',// | |
| '/он(\.|\s+)/', | |
| '/ор(\.|\s+)/', | |
| '/ой(\.|\s+)/', | |
| '/оч(\.|\s+)/', | |
| '/от(\.|\s+)/', | |
| '/у(\.|\s+)/', | |
| '/уг(\.|\s+)/', | |
| '/че(\.|\s+)/', | |
| ); | |
| if($out = @$_POST['text']){ | |
| $out = preg_replace('/([,:\/])/', ' \1 ', $out); | |
| $i=0; | |
| // while($out != $out = preg_replace($sokr, '.', $out)); | |
| while($i++<10)$out = preg_replace($sokr, '.', $out); | |
| $out = preg_replace(array('/ ([,:\/]) /','/\s+/','/ \./','/\.\./'),array('\1',' ','.','.'), $out); | |
| echo $out; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment