FerreroJeremy / ln2sql

A tool to query a database in natural language
GNU General Public License v3.0
510 stars 200 forks source link

Module not found Error #37

Closed nikhilv-quantela closed 6 years ago

nikhilv-quantela commented 6 years ago
  1. Git cloned the package
  2. Ran setup.py install
  3. Tried python ln2sql_gui.py

Error:-

D:\work_parts\j\ln2sql\ln2sql>python ln2sql_gui.py
Traceback (most recent call last):
  File "ln2sql_gui.py", line 6, in <module>
    from .ln2sql import Ln2sql
ModuleNotFoundError: No module named '__main__.ln2sql'; '__main__' is not a package
nikhilv-quantela commented 6 years ago

Update

In case of recreating the results of command json output got the following error.

Some aid would be really helpful. @FerreroJeremy @shashank88

D:\work_parts\j\ln2sql>python -m ln2sql.main -d database_store/city.sql -l lang_store/english.csv -i "Count how many city there are with the name blob?" -j output.json -t D:\work_parts\j\ln2sql\ln2sql\thesaurus_store\th_english.dat -s D:\work_parts\j\ln2sql\ln2sql\stopwords\english.txt
Traceback (most recent call last):
  File "C:\Users\nik\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\nik\Anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\work_parts\j\ln2sql\ln2sql\main.py", line 26, in <module>
    main()
  File "D:\work_parts\j\ln2sql\ln2sql\main.py", line 22, in main
    stopwords_path=args.stopwords,
  File "D:\work_parts\j\ln2sql\ln2sql\ln2sql.py", line 32, in __init__
    self.stopwordsFilter.load(stopwords_path)
  File "D:\work_parts\j\ln2sql\ln2sql\stopwordFilter.py", line 37, in load
    lines = f.read().split('\n')
  File "C:\Users\nik\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 11308: character maps to <undefined>
maverickjoy commented 6 years ago

I would suggest, if you want to retrieve the SQL query for further processing, rather than parsing the Json file, wont be a better way to do it , you should be editing the code and doing something like : in main files

ln2sqlObj = ln2sql(str(database_path), str(input_sentence), str(language_path), thesaurus_path, json_output_path)

return ln2sqlObj.getQuery()

def getSql(query, sqlDump, outputFile=None):
    # unit test
    # args = ['-d', 'ln2sqlmodule/emp_dump.sql', '-l', 'ln2sqlmodule/lang/english.csv', '-i', query, '-j', 'ln2sqlmodule/output.json','-x']
    # args = ['-d', 'ln2sqlmodule/emp_dump.sql', 'ln2sqlmodule/lang/english.csv', '-i', query, '-j', 'ln2sqlmodule/output.json']

    # args = ['-d', 'ln2sqlmodule/timesheet.sql', '-l',
    #         'ln2sqlmodule/lang/english.csv', '-i', query, '-j', 'ln2sqlmodule/output.json']

    args = ['-d', sqlDump,
            '-l', os.path.dirname(os.path.abspath(__file__)) + '/lang/english.csv',
            '-i', query,
            '-j', outputFile]

    sql = __main__(args)

    return str(sql)

This is a kind of pseudo code, refactoring would be needed, I did something like this on the same lines long time back. Unfortunately, I don't have enough time to give complete support on this as I am presently working on something completely different.

Regards Vikram

jlippold commented 6 years ago

This project needs some setup instructions. The README doesnt help, there's tons of cryptic error messages

jlippold commented 6 years ago

This fork works https://github.com/maverickjoy/ln2sql

siddharthchauhan commented 4 years ago

Code is not workingk, can you upload the code with all the issues fixed?

lucascasserone commented 4 years ago

don't work for me :(

krishna9626 commented 4 years ago

Same Error....code is not working