Changeset 7fb0101 in git


Ignore:
Timestamp:
Aug 5, 2019, 11:00:30 PM (4 years ago)
Author:
Murray Heymann <heymann.murray@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
bb8cdbbda3604b0b59579d1fa969c8d5ca30f07b
Parents:
2f9e3f171a90f561e7a3c81734eb72998dc8fe82
git-author:
Murray Heymann <heymann.murray@gmail.com>2019-08-05 23:00:30+02:00
git-committer:
Murray Heymann <heymann.murray@gmail.com>2019-08-05 23:00:37+02:00
Message:
Begin writing c functions to interact with python3
Location:
machine_learning
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • machine_learning/.coveragerc

    r2f9e3f r7fb0101  
    11[run]
    22branch = True
    3 omit = tests/*, *__init__.py, predictor_runner.py
     3omit = *tests/*, *__init__.py, *predictor_runner.py
    44
    55
  • machine_learning/ml_python/common/constants.py

    r2f9e3f r7fb0101  
    77EXTRACT_SCRIPT = "extract.lib"
    88KEYWORDS_FILE = "keywords.txt"
    9 VECTORS_NPY = "vectors.npy"
    10 HELPFILE_NPY = "helpfilelist.npy"
     9VECTORS_NPY = ".vectors.npy"
     10HELPFILE_NPY = ".helpfilelist.npy"
    1111
    1212HELP_FILE_URL = "ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/src/4-1-2/doc.tbz2"
  • machine_learning/ml_python/common/lookuptable.py

    r2f9e3f r7fb0101  
    5555    # read from the file created by singular
    5656    dictionary = read_dictionary()
    57     print(dictionary)
    5857
    5958    # sort alphabetically
    6059    dictionary = np.sort(np.unique(dictionary))
    61     print(dictionary)
    6260
    6361    # write back to the same file
     
    6664            file.write(word + "\n")
    6765
     66    return dictionary
    6867
    6968
     
    9796
    9897    return (vectors, file_list)
     98
     99def init_table_on_system():
     100    """
     101    check whether the various files exist, and create if necessary.
     102    """
     103    # check for and download help files if necessary
     104    tbz2_path = os.path.join(HELP_FILE_PATH, "helpfiles.tbz2")
     105    if not os.path.isdir(HELP_FILE_PATH) or not os.path.isfile(tbz2_path):
     106        fetch_tbz2_data()
     107
     108    # Use Singular to extract the keywords and save in a file.
     109    if not os.path.isfile(KEYWORDS_FILE):
     110        dictionary = extract_keywords()
     111    else:
     112        dictionary = None
     113
     114
     115    if not os.path.isfile(VECTORS_NPY) or not os.path.isfile(HELPFILE_NPY):
     116        vectors, file_list = create_table(dictionary=dictionary,
     117                                          attempt_cached=False)
  • machine_learning/ml_python/tests/common/test_keyword_vectors.py

    r2f9e3f r7fb0101  
    7373        print("Testing create_vector_dictionary function:")
    7474
    75         read_dictionary()
     75        dictionary = read_dictionary()
    7676
    7777        print("Create Vector Dictionary with None as dictionary:")
     
    8282                          create_vector_dictionary,
    8383                          np.array([]))
    84         print()
     84        vec_dic = create_vector_dictionary(dictionary)
    8585
    8686    def test_vector_distance(self):
  • machine_learning/ml_python/tests/common/test_lookuptable.py

    r2f9e3f r7fb0101  
    66from common.lookuptable import *
    77from common.keyword_vector import count_occurances
    8 from common.constants import KEYWORDS_FILE
     8from common.constants import KEYWORDS_FILE, VECTORS_NPY, HELP_FILE_PATH
    99
    1010class TestLookuptableMethods(unittest.TestCase):
     
    3333        self.assertTrue((test_vec == vectors[1]).all())
    3434
     35    def test_init_table_on_system(self):
     36        tbz2_path = os.path.join(HELP_FILE_PATH, "helpfiles.tbz2")
     37        os.remove(tbz2_path)
     38        os.remove(KEYWORDS_FILE)
     39        os.remove(VECTORS_NPY)
     40
     41        init_table_on_system()
     42
     43        self.assertTrue(os.path.isfile(tbz2_path))
     44        self.assertTrue(os.path.isfile(KEYWORDS_FILE))
     45        self.assertTrue(os.path.isfile(VECTORS_NPY))
     46
     47        init_table_on_system()
     48
     49
    3550if __name__ == '__main__':
    3651    #cProfile.run("unittest.main()")
Note: See TracChangeset for help on using the changeset viewer.