Skip to content

Commit

Permalink
matching types
Browse files Browse the repository at this point in the history
  • Loading branch information
wowikc committed Mar 30, 2022
1 parent ab217cf commit 67fc536
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions paradigm_panes/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Handles paradigm generation.
"""

import string
from pathlib import Path
from .manager import *
from . import settings

Expand All @@ -19,7 +19,7 @@ def default_paradigm_manager() -> ParadigmManager:
"""

# Directory with paradigm layouts to load
layout_dir = settings.get_layouts_dir()
layout_dir = Path(settings.get_layouts_dir())

generator = strict_generator()

Expand Down
2 changes: 1 addition & 1 deletion paradigm_panes/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def default_size(self, paradigm_name: str):
sizes = list(self.sizes_of(paradigm_name))
return sizes[0]

def _layout_sizes_or_raise(self, paradigm_name) -> dict[str, ParadigmLayout]:
def _layout_sizes_or_raise(self, paradigm_name) -> ParadigmLayout:
"""
Returns the sizes of the paradigm with the given name.
Expand Down
12 changes: 9 additions & 3 deletions paradigm_panes/pane_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ def all_analysis_template_tags(self, paradigm_type: str) -> Collection[tuple]:
building a paradigm table, not the results of analyzing some input
string.
"""
pg = default_paradigm_manager()
all_template_tags = pg.all_analysis_template_tags(paradigm_type)
return all_template_tags
if (settings.is_setup_complete()):
if paradigm_type is not None:
pg = default_paradigm_manager()
all_template_tags = pg.all_analysis_template_tags(paradigm_type)
return all_template_tags
else:
raise Exception("Paradigm layout specification is missing.")
else:
raise Exception("FST and Layouts resources are not configured correctly.")

def paradigm_for(self, paradigm_manager: ParadigmManager, paradigm_type: str, fst_lemma: str, paradigm_size: str) -> Optional[Paradigm]:
"""
Expand Down
2 changes: 2 additions & 0 deletions paradigm_panes/running_scenario.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Scenario 1
# Sets layouts and fst resources and creates a paradigm of amisk, which is NA paradigm
# need to update resources directories based on your system

import paradigm_panes
pg = paradigm_panes.PaneGenerator()
pg.set_layouts_dir("/home/ubuntu/cmput401/paradigm-panes/paradigm_panes/resources/layouts")
Expand All @@ -11,6 +12,7 @@ pg.generate_pane(lemma, p_type)

# Scenario 2
# Sets layouts, fst, and tag style (or default) and returns all_analysis_template_tags from a paradigm manager

import paradigm_panes
pg = paradigm_panes.PaneGenerator()
pg.set_layouts_dir("/home/ubuntu/cmput401/paradigm-panes/paradigm_panes/resources/layouts")
Expand Down
2 changes: 1 addition & 1 deletion paradigm_panes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def set_fst_filepath(filepath: str) -> None:
global STRICT_GENERATOR_FST_FILEPATH
STRICT_GENERATOR_FST_FILEPATH = filepath
else:
raise FileDoesNotMatch(f"file {filepath.as_posix()!r} does not exist or does not end in \".hfstol\".")
raise FileDoesNotMatch(f"file {Path(filepath).as_posix()!r} does not exist or does not end in \".hfstol\".")

def get_fst_filepath() -> str:
"""
Expand Down

0 comments on commit 67fc536

Please sign in to comment.