Datasets:
Download docs/books-strict-processing/test_strict.py from xytpai/datax-open: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/datasets/xytpai/datax-open/resolve/main/docs/books-strict-processing/test_strict.py
- Command line
-
hf download hf://datasets/xytpai/datax-open/docs/books-strict-processing/test_strict.py
-
curl -L -o test_strict.py https://huggingface.co/datasets/xytpai/datax-open/resolve/main/docs/books-strict-processing/test_strict.py
1.01 kB
| import strict_rules as s | |
| def check(t,repo,title): | |
| out,rem=s.clean(t,repo,title);rebuilt=[];a=b=0 | |
| for r in rem: | |
| n=r['start']-a;rebuilt += [out[b:b+n],r['text']];b+=n;a=r['end'] | |
| rebuilt.append(out[b:]);assert ''.join(rebuilt)==t | |
| return out,rem | |
| x="```text\nSave as PDF\nSkip to main content\n```\n\\[x+y=3\\]\n" | |
| assert check(x,'common-pile/libretexts_filtered','Test')[0]==x | |
| x="Title\nSkip to main content\nLast updated\nSome content is preserved.\n" | |
| out,rem=check(x,'common-pile/libretexts_filtered','Title') | |
| assert 'Some content is preserved.' in out and 'Skip to main content' not in out | |
| x='Produced by David Widger\n\n'+('Long narrative. '*150)+'\n\nEnd of Project Gutenberg\'s My Book\n' | |
| out,rem=check(x,'common-pile/project_gutenberg_filtered','My Book') | |
| assert 'Produced by' not in out and 'End of Project' not in out | |
| x='```python\nprint("Grosset & Dunlap")\n```\n' | |
| assert check(x,'common-pile/project_gutenberg_filtered','Code book')[0]==x | |
| print('Strict removal and protected-math/code tests OK') | |