Is there a similar function - DictionaryBasedBreakIterator

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tunyawat
Forum Newbie
Posts: 3
Joined: Fri Sep 05, 2008 2:09 am

Is there a similar function - DictionaryBasedBreakIterator

Post by tunyawat »

In Java there is a function called DictionaryBasedBreakIterator. The main purpose of this function is to break the word based on a dictionary file.

http://icu-project.org/apiref/icu4j/com ... rator.html

For example, when being used, it can break the word "DictionaryBasedBreakIterator" into "dictionary" "based" "break" "iterator".

Is there a similar function in PHP

Thanks
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Is there a similar function - DictionaryBasedBreakIterator

Post by onion2k »

No. It should be fairly easy to write your own version by the sounds of it though.
User avatar
starram
Forum Commoner
Posts: 58
Joined: Thu Apr 10, 2008 1:27 am
Location: India
Contact:

Re: Is there a similar function - DictionaryBasedBreakIterator

Post by starram »

You may check for the uppercase words and explode or break the string using that.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Is there a similar function - DictionaryBasedBreakIterator

Post by onion2k »

starram wrote:You may check for the uppercase words and explode or break the string using that.
If you read the link the original poster posted you'll see it's used for things like breaking down sentences written in Thai (where they don't use spaces). I doubt it'll always be in nice camel caps. That approach won't work.
User avatar
starram
Forum Commoner
Posts: 58
Joined: Thu Apr 10, 2008 1:27 am
Location: India
Contact:

Re: Is there a similar function - DictionaryBasedBreakIterator

Post by starram »

ok, I just read your Post.
tunyawat
Forum Newbie
Posts: 3
Joined: Fri Sep 05, 2008 2:09 am

Re: Is there a similar function - DictionaryBasedBreakIterator

Post by tunyawat »

onion2k, you are right! I'm going to use this function to break the Thai words. (and there is no cap-lock between words)

what I really want to know is how to make "thisisateststring" into "this is a test string"
Post Reply