-
-
Notifications
You must be signed in to change notification settings - Fork 37
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 #183 from opensanctions/just-index
Add a slim enricher base class for config/filtering, some tests and cleanup
- Loading branch information
Showing
6 changed files
with
74 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
import logging | ||
from pathlib import Path | ||
from typing import Type, Optional | ||
|
||
from nomenklatura.index.index import Index | ||
from nomenklatura.index.common import BaseIndex | ||
from nomenklatura.store import View | ||
from nomenklatura.dataset import DS | ||
from nomenklatura.entity import CE | ||
|
||
log = logging.getLogger(__name__) | ||
INDEX_TYPES = ["tantivy", Index.name] | ||
|
||
|
||
def get_index( | ||
view: View[DS, CE], path: Path, type_: Optional[str] | ||
) -> BaseIndex[DS, CE]: | ||
"""Get the best available index class to use.""" | ||
clazz: Type[BaseIndex[DS, CE]] = Index[DS, CE] | ||
if type_ == "tantivy": | ||
try: | ||
from nomenklatura.index.tantivy_index import TantivyIndex | ||
|
||
clazz = TantivyIndex[DS, CE] | ||
except ImportError: | ||
log.warning("`tantivy` is not available, falling back to in-memory index.") | ||
|
||
index = clazz(view, path) | ||
index.build() | ||
return index | ||
|
||
|
||
__all__ = ["BaseIndex", "Index", "TantivyIndex", "get_index"] | ||
__all__ = ["BaseIndex", "Index"] |
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