{"action":"closed","issue":{"url":"https://api.github.com/repos/nltk/nltk/issues/903","labels_url":"https://api.github.com/repos/nltk/nltk/issues/903/labels{/name}","comments_url":"https://api.github.com/repos/nltk/nltk/issues/903/comments","events_url":"https://api.github.com/repos/nltk/nltk/issues/903/events","html_url":"https://github.com/nltk/nltk/issues/903","id":59333592,"number":903,"title":"nltk grammar checker","user":{"login":"Besitypanacea","id":11234172,"avatar_url":"https://avatars.githubusercontent.com/u/11234172?v=3","gravatar_id":"","url":"https://api.github.com/users/Besitypanacea","html_url":"https://github.com/Besitypanacea","followers_url":"https://api.github.com/users/Besitypanacea/followers","following_url":"https://api.github.com/users/Besitypanacea/following{/other_user}","gists_url":"https://api.github.com/users/Besitypanacea/gists{/gist_id}","starred_url":"https://api.github.com/users/Besitypanacea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Besitypanacea/subscriptions","organizations_url":"https://api.github.com/users/Besitypanacea/orgs","repos_url":"https://api.github.com/users/Besitypanacea/repos","events_url":"https://api.github.com/users/Besitypanacea/events{/privacy}","received_events_url":"https://api.github.com/users/Besitypanacea/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-28T08:59:15Z","updated_at":"2015-02-28T09:03:06Z","closed_at":"2015-02-28T09:03:06Z","body":"\r\n\r\nI am trying to implement a python grammar checker on python. I  already have the part of the code that needs modification. What I need is a code that can highlight text on the searched words that need replacing by showing a drop down list of better suggestions when you point at the text. The code should highlight text with a different color and warn the user before a replacement is made like what microsoft word does. My code on the terminal does not do that at all. It just changes the words without warning the user which can be risky. I will share with you the part of the code that needs modification. Please help!\r\n\r\nPlease tell me the parts that need modification or changing:\r\n\r\nclass WordReplacer(object):\r\n\t\t\tdef __init__(self, word_map):\r\n\t\t\t\tself.word_map = word_map\r\n\t\r\n\t\t\tdef replace(self, word):\r\n\t\t\t\treturn self.word_map.get(word, word)\r\n\r\n\r\nclass CsvWordReplacer(WordReplacer):\r\n\t\t\tdef __init__(self, fname):\r\n\t\t\t\tword_map = {}\r\n\t\t\t\tfor line in csv.reader(open(fname)):\r\n\t\t\t\t\tword, syn = line\r\n\t\t\t\t\tword_map[word] = syn\r\n\t\t\t\tsuper(CsvWordReplacer, self).__init__(word_map)\r\n\r\n\r\nclass YamlWordReplacer(WordReplacer):\r\n\t\t\tdef __init__(self, fname):\r\n\t\t\t\tword_map = yaml.load(open(fname))\r\n\t\t\t\tsuper(YamlWordReplacer, self).__init__(word_map)\r\n\r\n\r\n\r\nclass AntonymReplacer(object):\r\n\t\t\tdef replace(self, word, pos=None):\r\n\t\t\t\tantonyms = set()\r\n\t\t\t\tfor syn in wordnet.synset(word, pos=pos):\r\n\t\t\t\t\tfor lemma in syn.lemmas:\r\n\t\t\t\t\t\tfor antonym in lemma.antonyms():\r\n\t\t\t\t\t\t\tantonyms.add(antonym.name)\r\n\t\t\t\tif len(antonyms) == 1:\r\n\t\t\t\t\treturn antonyms.pop()\r\n\r\n\t\t\t\telse:\r\n\t\t\t\t\treturn None\r\n\r\n\r\n\t\t\tdef replace_negations(self, sent):\r\n\t\t\t\ti, l = 0, len(sent)\r\n\t\t\t\twords = []\r\n\t\t\t\twhile i < l:\r\n\t\t\t\t\tword = sent[i]\r\n\t\t\t\t\tif word == 'not' and i+1 < l:\r\n\t\t\t\t\t\tant = self.replace(sent[i+1])\r\n\t\t\t\t\t\tif ant:\r\n\t\t\t\t\t\t\twords.append(ant)\r\n\t\t\t\t\t\t\ti += 2\r\n\t\t\t\t\t\t\tcontinue\r\n\t\t\t\t\t\twords.append(word)\r\n\t\t\t\t\t\ti += 1\r\n\t\t\t\t\treturn words\r\n\r\n\r\nclass AntonymWordReplacer(WordReplacer, AntonymReplacer):\r\n\t\tpass\r\n"}}