Skip to content

Instantly share code, notes, and snippets.

@myedibleenso
Created March 14, 2023 15:33
Show Gist options
  • Select an option

  • Save myedibleenso/d35048e1f22d0a7ddac76f11cd3f5326 to your computer and use it in GitHub Desktop.

Select an option

Save myedibleenso/d35048e1f22d0a7ddac76f11cd3f5326 to your computer and use it in GitHub Desktop.

Revisions

  1. myedibleenso created this gist Mar 14, 2023.
    24 changes: 24 additions & 0 deletions example.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # conda create -n "odinsynth-redux" python=3.9 ipython
    # clone https://github.com/lum-ai/odinson-gateway
    # pip install ".[all]"

    # from the iPython REPL
    from typing import Dict, Any, List, Text
    from odinson.gateway import OdinsonGateway, Document
    import json

    # FIXME: our specification of Odinson documents.
    # Assumes these have been loaded as a seq of Python dicts
    specs: List[Dict[Text, Any]] = []
    docs = [Document.from_json(spec) for spec in specs]
    engine = OdinsonGateway.open_memory_index(docs)
    # your rule
    rule: Text = ""
    results = engine.search(pattern=rule)

    print(f"total hits: {results.total_hits}")
    for scoredoc in results.docs:
    print(f"Lucene doc ID: {scoredoc.doc}")
    print(f"start: {scoredoc.start}")
    print(f"end: {scoredoc.end}\n")
    # also named_captures