diff options
Diffstat (limited to 'data')
-rw-r--r-- | data/csv.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/data/csv.py b/data/csv.py index 2a8115b..2b1e202 100644 --- a/data/csv.py +++ b/data/csv.py | |||
@@ -130,6 +130,25 @@ class VlpnDataItem(NamedTuple): | |||
130 | collection: list[str] | 130 | collection: list[str] |
131 | 131 | ||
132 | 132 | ||
133 | def keyword_filter( | ||
134 | placeholder_tokens: Optional[list[str]], | ||
135 | collection: Optional[list[str]], | ||
136 | exclude_collections: Optional[list[str]], | ||
137 | item: VlpnDataItem | ||
138 | ): | ||
139 | cond1 = placeholder_tokens is None or any( | ||
140 | keyword in part | ||
141 | for keyword in placeholder_tokens | ||
142 | for part in item.prompt | ||
143 | ) | ||
144 | cond2 = collection is None or collection in item.collection | ||
145 | cond3 = exclude_collections is None or not any( | ||
146 | collection in item.collection | ||
147 | for collection in exclude_collections | ||
148 | ) | ||
149 | return cond1 and cond2 and cond3 | ||
150 | |||
151 | |||
133 | class VlpnDataModule(): | 152 | class VlpnDataModule(): |
134 | def __init__( | 153 | def __init__( |
135 | self, | 154 | self, |