#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2011 Ciaran Farrell, Juergen Weigert
# All Rights Reserved.

# This program is free software; you can redistribute it and/ormodify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, see the followig website:
# https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt

import sys
from pywumanber import WuManber
from optparse import OptionParser
parser = OptionParser()

parser.add_option("-c", "--case", dest="case", action="store_true",
                help="Use this flag to force case sensitive matching.")
parser.add_option("-v", "--verbose",
                action="store_true", dest="verbose", default=False,
                help="Print the results of the search")

(options, args) = parser.parse_args()
if len(args) != 2:
  parser.error("Expected exactly 2 arguments (keywords and text)")
wu = WuManber(args[0],args[1])
if options.case:
  nocase = 0
else:
  nocase = 1
count = wu.search_text(nocase=nocase,verbose=options.verbose)
sys.stdout.write("Matches found: %d\n"%count)
for k in wu.keydict.keys():
  print "%s: %s"%(wu.keywords[k],wu.keydict[k])
