-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2580 from ziv17/2567-use-segment-id-in-news-flash
2567 use segment id in news flash
- Loading branch information
Showing
21 changed files
with
226 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,4 @@ | ||
resolution_dict = { | ||
"מחוז": ["region_hebrew"], | ||
"נפה": ["district_hebrew"], | ||
"עיר": ["yishuv_name"], | ||
"רחוב": ["yishuv_name", "street1_hebrew"], | ||
"צומת עירוני": ["yishuv_name", "street1_hebrew", "street2_hebrew"], | ||
"כביש בינעירוני": ["road1", "road_segment_name"], | ||
"צומת בינעירוני": ["non_urban_intersection", "non_urban_intersection_hebrew", "road1", "road2"], | ||
"אחר": [ | ||
"region_hebrew", | ||
"district_hebrew", | ||
"yishuv_name", | ||
"street1_hebrew", | ||
"street2_hebrew", | ||
"non_urban_intersection_hebrew", | ||
"road1", | ||
"road2", | ||
"road_segment_name", | ||
"road_segment_id", | ||
], | ||
} | ||
|
||
fields_to_resolution = { | ||
("yishuv_name", "street1_hebrew"): "רחוב", | ||
("road_segment_name", "road1"): "כביש בינעירוני", | ||
} | ||
""" | ||
resolution_dict is depracated. Its functionality was moved to class | ||
ResolutionFields, in module resolution_fields in same directory. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from typing import Union, List, Set, Container | ||
from anyway.backend_constants import BE_CONST | ||
|
||
|
||
class ResolutionFields: | ||
RC = BE_CONST.ResolutionCategories | ||
__required_fields = { | ||
"מחוז": ["region_hebrew"], | ||
"נפה": ["district_hebrew"], | ||
"עיר": ["yishuv_name"], | ||
"רחוב": ["yishuv_name", "street1_hebrew"], | ||
"צומת עירוני": ["yishuv_name", "street1_hebrew", "street2_hebrew"], | ||
"כביש בינעירוני": ["road1", "road_segment_id"], | ||
"צומת בינעירוני": [ | ||
"non_urban_intersection", | ||
"non_urban_intersection_hebrew", | ||
"road1", | ||
"road2", | ||
], | ||
"אחר": [ | ||
"region_hebrew", | ||
"district_hebrew", | ||
"yishuv_name", | ||
"street1_hebrew", | ||
"street2_hebrew", | ||
"non_urban_intersection_hebrew", | ||
"road1", | ||
"road2", | ||
"road_segment_name", | ||
"road_segment_id", | ||
], | ||
} | ||
__possible_fields = { | ||
"מחוז": __required_fields[RC.REGION.value], | ||
"נפה": __required_fields[RC.DISTRICT.value], | ||
"עיר": __required_fields[RC.CITY.value], | ||
"רחוב": __required_fields[RC.STREET.value], | ||
"צומת עירוני": __required_fields[RC.URBAN_JUNCTION.value], | ||
"כביש בינעירוני": ["road1", "road_segment_id", "road_segment_name"], | ||
"צומת בינעירוני": __required_fields[RC.SUBURBAN_JUNCTION.value], | ||
"אחר": __required_fields[RC.OTHER.value], | ||
} | ||
__all_fields = set() | ||
|
||
@classmethod | ||
def get_fields(cls, d: dict, res: Union[BE_CONST.ResolutionCategories, str]) -> List[str]: | ||
if isinstance(res, BE_CONST.ResolutionCategories): | ||
res = res.value | ||
if res in d: | ||
return d[res] | ||
else: | ||
raise ValueError(f"ResolutionFields:{res}: not a resolution") | ||
|
||
@classmethod | ||
def get_possible_fields(cls, res: Union[BE_CONST.ResolutionCategories, str]) -> List[str]: | ||
return cls.get_fields(cls.__possible_fields, res) | ||
|
||
@classmethod | ||
def get_required_fields(cls, res: Union[BE_CONST.ResolutionCategories, str]) -> List[str]: | ||
return cls.get_fields(cls.__required_fields, res) | ||
|
||
@classmethod | ||
def get_all_location_fields(cls) -> Set[str]: | ||
if not cls.__all_fields: | ||
for fields in cls.__possible_fields.values(): | ||
cls.__all_fields.update(fields) | ||
return cls.__all_fields | ||
|
||
@classmethod | ||
def is_resolution_valid(cls, res: str) -> bool: | ||
return res in cls.__possible_fields | ||
|
||
@classmethod | ||
def get_supported_resolution_of_fields(cls, fields: Container[str]) -> List[str]: | ||
fields = set(fields) | ||
res = list( | ||
filter( | ||
lambda r: set(cls.get_required_fields(r)) <= fields, BE_CONST.SUPPORTED_RESOLUTIONS | ||
) | ||
) | ||
return res |
Oops, something went wrong.