This file contains hidden or 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
"""Join two lists of items using a language model.""" | |
import logging | |
from typing import Any, Dict, Optional, Tuple, List | |
import numpy as np | |
from numpy.typing import ArrayLike | |
import openai | |
import tqdm | |
logger = logging.getLogger(__name__) |
This file contains hidden or 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
case class Edge[T, S](source: T, dest: T, attr: S) | |
case class Vertex[T, S](id: T, attr: S) | |
case class EdgeTriplet[T, S, Q](source: Vertex[T, Q], dest: Vertex[T, Q], edge: Edge[T, S]) | |
abstract class Graph[T: Ordering : ClassTag, S: ClassTag, Q: ClassTag, M[_], X[_, _, _] <: Graph[_, _, _, M, X]](val edges: M[Edge[T, S]], val vertices: M[Vertex[T, Q]]) { | |
def triplets: M[EdgeTriplet[T, S, Q]] | |
def outerJoinVertices[U: ClassTag, VD2: ClassTag](other: M[(T, U)])(mapFunc: (T, Q, Option[U]) => VD2): Graph[T, S, VD2, M, X] | |
def joinVertices[U: ClassTag, VD2: ClassTag](other: M[(T, U)])(mapFunc: (T, Q, U) => VD2): Graph[T, S, VD2, M, X] |
This file contains hidden or 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
/** | |
* Fold with map side aggregation using a monoid. | |
* */ | |
class FoldExtension[T](pipe: TypedPipe[T]) { | |
def foldByKey[K, V, B](z : B)(fn : scala.Function2[B, V, B]) | |
(implicit ev : scala.Predef.<:<[T, scala.Tuple2[K, V]], | |
ord : scala.Ordering[K], | |
aggPlus : Semigroup[B]) : UnsortedGrouped[K, B] = { | |
val sg = new Semigroup[Either[V, B]] { |