• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 //  Distributed under the Boost Software License, Version 1.0. (See
5 //  accompanying file LICENSE_1_0.txt or copy at
6 //  http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #include <boost/locale.hpp>
9 #include <iostream>
10 #include <cassert>
11 #include <ctime>
12 
main()13 int main()
14 {
15     using namespace boost::locale;
16     using namespace std;
17 
18     generator gen;
19     // Make system default locale global
20     std::locale loc = gen("");
21     locale::global(loc);
22     cout.imbue(loc);
23 
24 
25     string text="Hello World! あにま! Linux2.6 and Windows7 is word and number. שָלוֹם עוֹלָם!";
26 
27     cout<<text<<endl;
28 
29     boundary::ssegment_index index(boundary::word,text.begin(),text.end());
30     boundary::ssegment_index::iterator p,e;
31 
32     for(p=index.begin(),e=index.end();p!=e;++p) {
33         cout<<"Part ["<<*p<<"] has ";
34         if(p->rule() & boundary::word_number)
35             cout<<"number(s) ";
36         if(p->rule() & boundary::word_letter)
37             cout<<"letter(s) ";
38         if(p->rule() & boundary::word_kana)
39             cout<<"kana character(s) ";
40         if(p->rule() & boundary::word_ideo)
41             cout<<"ideographic character(s) ";
42         if(p->rule() & boundary::word_none)
43             cout<<"no word characters";
44         cout<<endl;
45     }
46 
47     index.map(boundary::character,text.begin(),text.end());
48 
49     for(p=index.begin(),e=index.end();p!=e;++p) {
50         cout<<"|" <<*p ;
51     }
52     cout<<"|\n\n";
53 
54     index.map(boundary::line,text.begin(),text.end());
55 
56     for(p=index.begin(),e=index.end();p!=e;++p) {
57         cout<<"|" <<*p ;
58     }
59     cout<<"|\n\n";
60 
61     index.map(boundary::sentence,text.begin(),text.end());
62 
63     for(p=index.begin(),e=index.end();p!=e;++p) {
64         cout<<"|" <<*p ;
65     }
66     cout<<"|\n\n";
67 
68 }
69 
70 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
71 
72 // boostinspect:noascii
73