at 2009-05-17
in Announcements
by friebe
(0 comments)
The new text.spelling package provides a wrapper around the pspell extension and provides an easy way to spell-check texts. Here's the basic usage:
<?php $spell= new SpellChecker('en'); $spell->check('Hello'); $spell->check('Bahnhof'); $spell->suggestionsFor('delibrate'); ?>
To spell-check an entire text, you can use the text.Tokenizer implementations to split up the text into words:
<?php $st= new StreamTokenizer(new FileInputStream(new File('candidate.txt')), " \r\n\t.:,;-")); while ($st->hasMoreTokens()) { $word= $st->nextToken(); if (is_numeric($word)) continue; if (!$spell->check($word)) { } } ?>
|
Subscribe
You can subscribe to the XP framework's news by using RSS syndication.
CategoriesNews General PHP5 Announcements RFCs Further reading Examples Editorial EASC Experiments Unittests Databases 5.8-SERIES
RelatedFind related articles by a search for «New».
|