From fe7055130b9d20c053ce50751a4521c86f20882e Mon Sep 17 00:00:00 2001 From: syntactic Date: Thu, 17 May 2018 16:45:43 -0700 Subject: [PATCH 1/3] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4bcd760 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 syntactic + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 680ad42d091ea274eca8164a5d56e428d1ec7599 Mon Sep 17 00:00:00 2001 From: syntactic Date: Thu, 17 May 2018 16:54:34 -0700 Subject: [PATCH 2/3] I'm updating the copyright information contained within the source code - I didn't actually think that anyone would be using this code at all, so previously the information was invalid. I'm copying the contents of the LICENSE file into the header comments of the Python source. --- DeterministicGenerator.py | 47 +++++++++++++++++------------------ JSGFGrammar.py | 45 +++++++++++++++++---------------- JSGFParser.py | 43 +++++++++++++++----------------- ProbabilisticGenerator.py | 52 +++++++++++++++++++-------------------- 4 files changed, 89 insertions(+), 98 deletions(-) diff --git a/DeterministicGenerator.py b/DeterministicGenerator.py index a6f526c..782a6cb 100644 --- a/DeterministicGenerator.py +++ b/DeterministicGenerator.py @@ -1,3 +1,25 @@ +# @copyright: MIT License +# Copyright (c) 2018 syntactic (Pastèque Ho) +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# @summary: This file generates all strings described by a non-recursive JSGF grammar. +# Run it by entering into the command line: python DeterministicGenerator.py +# where is the path to the JSGF grammar. +# @since: 2014/06/02 + """ This file deterministically generates strings from a JSGF Grammar, whether there are \ weights defined in rules or not. It requires one argument: the path to the JSGF\ @@ -13,31 +35,6 @@ a segmentation fault. """ -# @copyright: (c)Copyright 2014, THC All Rights Reserved. -# The source code contained or described here in and all documents related -# to the source code ("Material") are owned by THC or its -# suppliers or licensors. Title to the Material remains with THC -# or its suppliers and licensors. The Material contains trade secrets and -# proprietary and confidential information of THC or its suppliers and -# licensors. - -# The Material is protected by worldwide copyright and trade secret laws and -# treaty provisions. No part of the Material may be used, copied, reproduced, -# modified, published, uploaded, posted, transmitted, distributed, or disclosed -# in any way without THC's prior express written permission. - -# No license under any patent, copyright, trade secret or other intellectual -# property right is granted to or conferred upon you by disclosure or delivery -# of the Materials, either expressly, by implication, inducement, estoppel or -# otherwise. Any license under such intellectual property rights must be express -# and approved by THC in writing. - -# @organization: THC Science -# @summary: This file generates all strings described by a non-recursive JSGF grammar. -# Run it by entering into the command line: python DeterministicGenerator.py -# where is the path to the JSGF grammar. -# @since: 2014/06/02 - import sys, itertools import JSGFParser as parser import JSGFGrammar as gram diff --git a/JSGFGrammar.py b/JSGFGrammar.py index 26e4a92..496b452 100644 --- a/JSGFGrammar.py +++ b/JSGFGrammar.py @@ -1,32 +1,31 @@ +# @copyright: MIT License +# Copyright (c) 2018 syntactic (Pastèque Ho) +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# @summary: This file lays out the class structure for a JSGF Grammar +# @since: 2014/06/02 + """ This file lays out the class structure for a JSGF Grammar. .. module:: JSGFGrammar -.. moduleauthor:: Timothy Ho +.. moduleauthor:: Pastèque Ho """ -# @copyright: (c)Copyright 2014, THC All Rights Reserved. -# The source code contained or described here in and all documents related -# to the source code ("Material") are owned by THC or its -# suppliers or licensors. Title to the Material remains with THC -# or its suppliers and licensors. The Material contains trade secrets and -# proprietary and confidential information of THC or its suppliers and -# licensors. - -# The Material is protected by worldwide copyright and trade secret laws and -# treaty provisions. No part of the Material may be used, copied, reproduced, -# modified, published, uploaded, posted, transmitted, distributed, or disclosed -# in any way without THC's prior express written permission. - -# No license under any patent, copyright, trade secret or other intellectual -# property right is granted to or conferred upon you by disclosure or delivery -# of the Materials, either expressly, by implication, inducement, estoppel or -# otherwise. Any license under such intellectual property rights must be express -# and approved by THC in writing. - -# @organization: THC Science -# @summary: This file lays out the class structure for a JSGF Grammar -# @since: 2014/06/02 + class JSGFExpression(): pass diff --git a/JSGFParser.py b/JSGFParser.py index a63f86e..b0ea976 100644 --- a/JSGFParser.py +++ b/JSGFParser.py @@ -1,3 +1,23 @@ +# @copyright: MIT License +# Copyright (c) 2018 syntactic (Pastèque Ho) +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# @summary: This file parses a JSGF Grammar and prints it out. +# @since: 2014/06/02 + """ This file parses a JSGF grammar file and returns a JSGFGrammar object. \ It uses the pyparsing module and defines a grammar for JSGF grammars. \ @@ -37,29 +57,6 @@ """ -# @copyright: (c)Copyright 2014, THC All Rights Reserved. -# The source code contained or described here in and all documents related -# to the source code ("Material") are owned by THC or its -# suppliers or licensors. Title to the Material remains with THC -# or its suppliers and licensors. The Material contains trade secrets and -# proprietary and confidential information of THC or its suppliers and -# licensors. - -# The Material is protected by worldwide copyright and trade secret laws and -# treaty provisions. No part of the Material may be used, copied, reproduced, -# modified, published, uploaded, posted, transmitted, distributed, or disclosed -# in any way without THC's prior express written permission. - -# No license under any patent, copyright, trade secret or other intellectual -# property right is granted to or conferred upon you by disclosure or delivery -# of the Materials, either expressly, by implication, inducement, estoppel or -# otherwise. Any license under such intellectual property rights must be express -# and approved by THC in writing. - -# @organization: THC Science -# @summary: This file parses a JSGF Grammar and prints it out. -# @since: 2014/06/02 - import sys import JSGFGrammar as gram from pyparsing import * diff --git a/ProbabilisticGenerator.py b/ProbabilisticGenerator.py index fbfc021..500327b 100644 --- a/ProbabilisticGenerator.py +++ b/ProbabilisticGenerator.py @@ -1,3 +1,28 @@ +#/usr/bin/python + +# @copyright: MIT License +# Copyright (c) 2018 syntactic (Pastèque Ho) +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# @summary: This file generates sentences from a PCFG in JSGF. Run it by entering +# in the command line: python ProbabilisticGenerator.py +# where is the path of the JSGF file, and is the number +# of strings you want to generate +# @since: 2014/06/02 + """ This file probabilistically generates strings from a JSGF grammar. It takes advantage \ of weights assigned to alternatives (separated by pipes) by choosing to \ @@ -17,33 +42,6 @@ weights if they are provided. """ -#/usr/bin/python -# @copyright: (c)Copyright 2014, THC All Rights Reserved. -# The source code contained or described here in and all documents related -# to the source code ("Material") are owned by THC or its -# suppliers or licensors. Title to the Material remains with THC -# or its suppliers and licensors. The Material contains trade secrets and -# proprietary and confidential information of THC or its suppliers and -# licensors. - -# The Material is protected by worldwide copyright and trade secret laws and -# treaty provisions. No part of the Material may be used, copied, reproduced, -# modified, published, uploaded, posted, transmitted, distributed, or disclosed -# in any way without THC's prior express written permission. - -# No license under any patent, copyright, trade secret or other intellectual -# property right is granted to or conferred upon you by disclosure or delivery -# of the Materials, either expressly, by implication, inducement, estoppel or -# otherwise. Any license under such intellectual property rights must be express -# and approved by THC in writing. - -# @organization: THC Science -# @summary: This file generates sentences from a PCFG in JSGF. Run it by entering -# in the command line: python ProbabilisticGenerator.py -# where is the path of the JSGF file, and is the number -# of strings you want to generate -# @since: 2014/06/02 - import sys, itertools, random, bisect, argparse import JSGFParser as parser import JSGFGrammar as gram From 907b91791abe523817b2c2f8e77c66a83d74935e Mon Sep 17 00:00:00 2001 From: syntactic Date: Fri, 18 May 2018 16:11:19 -0700 Subject: [PATCH 3/3] I've added an encoding header and setup file. Thanks to Thomas Sauvage for finding the encoding issue and also for the setup file. --- DeterministicGenerator.py | 1 + JSGFGrammar.py | 1 + JSGFParser.py | 1 + ProbabilisticGenerator.py | 1 + setup.py | 12 ++++++++++++ 5 files changed, 16 insertions(+) create mode 100644 setup.py diff --git a/DeterministicGenerator.py b/DeterministicGenerator.py index 782a6cb..8479736 100644 --- a/DeterministicGenerator.py +++ b/DeterministicGenerator.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # @copyright: MIT License # Copyright (c) 2018 syntactic (Pastèque Ho) # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/JSGFGrammar.py b/JSGFGrammar.py index 496b452..628d79f 100644 --- a/JSGFGrammar.py +++ b/JSGFGrammar.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # @copyright: MIT License # Copyright (c) 2018 syntactic (Pastèque Ho) # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/JSGFParser.py b/JSGFParser.py index b0ea976..7bb06cc 100644 --- a/JSGFParser.py +++ b/JSGFParser.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # @copyright: MIT License # Copyright (c) 2018 syntactic (Pastèque Ho) # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/ProbabilisticGenerator.py b/ProbabilisticGenerator.py index 500327b..4af9b29 100644 --- a/ProbabilisticGenerator.py +++ b/ProbabilisticGenerator.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- #/usr/bin/python # @copyright: MIT License diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..054fc21 --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from setuptools import setup, find_packages + +setup( + + name='JSGFTools', + version='1', + url='https://github.com/syntactic/JSGFTools', + author='timothyakho@gmail.com', + license='MIT' + +) \ No newline at end of file