Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

punctuation_filter.cc

Go to the documentation of this file.
00001 #include <plearn/base/general.h> 00002 00003 using namespace PLearn; 00004 00005 // usage : punctuation_filter < in.text > filtered_out.text 00006 00007 bool isLetter(char c) 00008 { 00009 return (c >= 65 && c <= 90) || (c >= 97 && c <= 122); 00010 } 00011 00012 bool isDigit(char c) 00013 { 00014 return (c >= 48 && c <= 57); 00015 } 00016 00017 bool isAlpha(char c) 00018 { 00019 return (isLetter(c) || isDigit(c)); 00020 } 00021 00022 bool isPunctuation(string word) 00023 { 00024 for (int i = 0; i < word.size(); i++) 00025 { 00026 if (isAlpha(word[i])) return false; 00027 } 00028 return true; 00029 } 00030 00031 int main(int argc, char** argv) 00032 { 00033 if (argc != 1) 00034 PLERROR("usage : punctuation_filter < in.text > filtered_out.text"); 00035 string word; 00036 while (true) 00037 { 00038 cin >> word; 00039 if (!cin) break; 00040 if (isPunctuation(word)) 00041 //cout << "<punctuation>" << " : " << word << endl; 00042 cout << "<punctuation>" << endl; 00043 else 00044 cout << word << endl; 00045 } 00046 } 00047

Generated on Tue Aug 17 16:03:19 2004 for PLearn by doxygen 1.3.7