File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+
3+ import re
4+
5+ import ica
6+
7+
8+ def main () -> None :
9+
10+ cli_args = ica .get_cli_args ()
11+ phrase = cli_args .args [0 ]
12+ if not phrase :
13+ raise Exception ("Phrase to count must be provided" )
14+ dfs = ica .get_dataframes (
15+ contact_name = cli_args .contact_name , timezone = cli_args .timezone
16+ )
17+ filtered_messages = dfs .messages [~ dfs .messages ["is_reaction" ]]
18+ count = (
19+ filtered_messages ["text" ]
20+ .str .findall (phrase , flags = re .IGNORECASE )
21+ .str .len ()
22+ .sum ()
23+ )
24+ print (f"The phrase '{ phrase } ' appears { count } times." )
25+
26+
27+ if __name__ == "__main__" :
28+ main ()
Original file line number Diff line number Diff line change @@ -64,6 +64,11 @@ def get_cli_args() -> argparse.Namespace:
6464 help = "the path of the file to export analyzer results to; required when"
6565 " exporting Excel (xlsx) files" ,
6666 )
67+ parser .add_argument (
68+ "args" ,
69+ nargs = "*" ,
70+ help = "any additional arguments you want to pass to the analyzer" ,
71+ )
6772
6873 return parser .parse_args ()
6974
You can’t perform that action at this time.
0 commit comments