Skip to content

getting a tip directly from command-line. #99

Open
@nixypanda

Description

@nixypanda

Can this be turned into a command-line utility. Something like this.

import json
from pprint import pprint
from sys import argv
from difflib import SequenceMatcher

def similar(a, b):
    return SequenceMatcher(None, a, b).ratio()

if __name__ == '__main__':
    SEARCH = ' '.join(argv[1:])
    DATA = None

    with open('tips.json') as data_file:
        DATA = json.load(data_file)

    MAX = max(DATA, key=lambda x: similar(SEARCH.lower(), x['title'].lower()))
    print(MAX)

Maybe if we get a better string similarity heuristic it would be better something like FuzzyWuzzy. Kindly share your thoughts on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions