|
| 1 | +#/usr/bin/python |
| 2 | + |
| 3 | +# @copyright: MIT License |
| 4 | +# Copyright (c) 2018 syntactic (Pastèque Ho) |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# The above copyright notice and this permission notice shall be included in all |
| 12 | +# copies or substantial portions of the Software. |
| 13 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 | +# SOFTWARE. |
| 20 | +# @summary: This file generates sentences from a PCFG in JSGF. Run it by entering |
| 21 | +# in the command line: python ProbabilisticGenerator.py <grammarFile> <numStrings> |
| 22 | +# where <grammarFile> is the path of the JSGF file, and <numString> is the number |
| 23 | +# of strings you want to generate |
| 24 | +# @since: 2014/06/02 |
| 25 | + |
1 | 26 | """
|
2 | 27 | This file probabilistically generates strings from a JSGF grammar. It takes advantage \
|
3 | 28 | of weights assigned to alternatives (separated by pipes) by choosing to \
|
|
17 | 42 | weights if they are provided.
|
18 | 43 | """
|
19 | 44 |
|
20 |
| -#/usr/bin/python |
21 |
| -# @copyright: (c)Copyright 2014, THC All Rights Reserved. |
22 |
| -# The source code contained or described here in and all documents related |
23 |
| -# to the source code ("Material") are owned by THC or its |
24 |
| -# suppliers or licensors. Title to the Material remains with THC |
25 |
| -# or its suppliers and licensors. The Material contains trade secrets and |
26 |
| -# proprietary and confidential information of THC or its suppliers and |
27 |
| -# licensors. |
28 |
| - |
29 |
| -# The Material is protected by worldwide copyright and trade secret laws and |
30 |
| -# treaty provisions. No part of the Material may be used, copied, reproduced, |
31 |
| -# modified, published, uploaded, posted, transmitted, distributed, or disclosed |
32 |
| -# in any way without THC's prior express written permission. |
33 |
| - |
34 |
| -# No license under any patent, copyright, trade secret or other intellectual |
35 |
| -# property right is granted to or conferred upon you by disclosure or delivery |
36 |
| -# of the Materials, either expressly, by implication, inducement, estoppel or |
37 |
| -# otherwise. Any license under such intellectual property rights must be express |
38 |
| -# and approved by THC in writing. |
39 |
| - |
40 |
| -# @organization: THC Science |
41 |
| -# @summary: This file generates sentences from a PCFG in JSGF. Run it by entering |
42 |
| -# in the command line: python ProbabilisticGenerator.py <grammarFile> <numStrings> |
43 |
| -# where <grammarFile> is the path of the JSGF file, and <numString> is the number |
44 |
| -# of strings you want to generate |
45 |
| -# @since: 2014/06/02 |
46 |
| - |
47 | 45 | import sys, itertools, random, bisect, argparse
|
48 | 46 | import JSGFParser as parser
|
49 | 47 | import JSGFGrammar as gram
|
|
0 commit comments