Skip to content

Commit

Permalink
Merge branch 'fix-script-call-28' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
SimGus committed Nov 25, 2019
2 parents 7fd43ce + 139c4bb commit 9b07778
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Fixed
- Parser opened file upon being created rather than when starting to parse, leading to parsing of the same file several types after resetting the system (issue [#28](https://github.com/SimGus/Chatette/issues/28))
- One escapable character was missing, leading to escape character not being removed for `]` (issue [#27](https://github.com/SimGus/Chatette/issues/27))

## [1.6.1] - 2019-11-11
Expand Down
1 change: 1 addition & 0 deletions TODOs.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<!-- - [ ] rewrite docstrings formatted as explained in *PEP257* -->
- [ ] replace `print` by `six.print_`?
- [ ] add more unit tests
- [ ] refactor facade (and its interactions with parser, generator and adapter)

### Improve performance
- [ ] cache the possible number of generatable examples for each unit
Expand Down
8 changes: 4 additions & 4 deletions chatette/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self,
master_file_path, output_dir_path=None, adapter_str="rasa",
base_filepath=None, local=False, seed=None, force_overwriting=False
):
self.master_file_path = master_file_path
if local:
self.output_dir_path = os.path.dirname(master_file_path)
else:
Expand All @@ -57,7 +58,7 @@ def __init__(self,
adapter_str, base_filepath
)

self.parser = Parser(master_file_path)
self.parser = Parser()
self.generator = None

@classmethod
Expand Down Expand Up @@ -91,14 +92,13 @@ def run(self):

def run_parsing(self):
"""Executes the parsing alone."""
self.parser.parse()
self.parser.parse_file(self.master_file_path)

def parse_file(self, file_path):
"""
Parses the new template file at `file_path` with the current parser.
"""
self.parser.open_new_file(file_path)
self.parser.parse()
self.parser.parse_file(file_path)

def run_generation(self, adapter_str=None):
""""
Expand Down
12 changes: 7 additions & 5 deletions chatette/parsing/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


class Parser(object):
def __init__(self, master_file_path):
def __init__(self, master_file_path=None):
if (
master_file_path is not None
and not isinstance(master_file_path, string_types)
Expand All @@ -47,7 +47,7 @@ def __init__(self, master_file_path):
self._master_filepath = master_file_path

self.input_file_manager = \
InputFileManager.get_or_create(master_file_path)
InputFileManager.get_or_create()
self.lexer = Lexer()
self.ast = AST.get_or_create()

Expand Down Expand Up @@ -77,12 +77,14 @@ def open_new_file(self, filepath):
print_warn(err_msg)


def parse(self):
def parse_file(self, file_path):
"""
Parses the template file(s) and translates them into an AST.
Parses the template file(s) at `file_path`
and translates them into an AST.
"""
self.open_new_file(file_path)
print_DBG(
"Parsing master file: " + \
"Parsing file: " + \
self.input_file_manager.get_current_file_name()
)

Expand Down
4 changes: 2 additions & 2 deletions tests/system-testing/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def get_or_create():
def run(self, template_filepath):
AST.reset_instance()

parser = Parser(template_filepath)
parser.parse()
parser = Parser()
parser.parse_file(template_filepath)

self.generator = Generator()
self.train_examples = list(self.generator.generate_train())
Expand Down

0 comments on commit 9b07778

Please sign in to comment.