Skip to content

Commit

Permalink
Merge commit '5a3bf16'
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 23, 2025
2 parents c51965d + 5a3bf16 commit 538fbbd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/core/gossamer-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ extension [TextType: Textual](text: TextType)
inline def superscript: TextType = TextType.map(text, hieroglyph.superscript(_).or(' '))

package proximityMeasures:
given Proximity as jaroDistance = (left, right) =>
given jaroDistance: Proximity = (left, right) =>
if left == right then 1.0 else
val maxDist: Int = left.length.max(right.length)/2 - 1
val found1 = new scm.BitSet(left.length)
Expand Down Expand Up @@ -332,20 +332,20 @@ package proximityMeasures:
else (matches.toDouble/left.length + matches.toDouble/right.length +
(matches - count/2.0)/matches)/3

given Proximity as prefixMatch = (left, right) =>
given prefixMatch: Proximity = (left, right) =>
val limit = left.length.min(right.length)

def recur(index: Int = 0): Int = if index >= limit then index else
if left.s.charAt(index) == right.s.charAt(index) then recur(index + 1) else index

recur()

given Proximity as jaroWinklerDistance = (left, right) =>
given jaroWinklerDistance: Proximity = (left, right) =>
val scale = 0.1
val distance = jaroDistance.distance(left, right)
distance + scale*prefixMatch.distance(left, right).min(4.0)*(1.0 - distance)

given Proximity as levenshteinDistance = (left, right) =>
given levenshteinDistance: Proximity = (left, right) =>
val m = left.s.length
val n = right.length
val old = new Array[Int](n + 1)
Expand All @@ -364,7 +364,7 @@ package proximityMeasures:

dist(n)

given Proximity as normalizedLevenshteinDistance = (left, right) =>
given normalizedLevenshteinDistance: Proximity = (left, right) =>
levenshteinDistance.distance(left, right)/left.length.max(right.length)

extension (text: into Text)
Expand Down Expand Up @@ -410,18 +410,18 @@ extension (buf: StringBuilder)
def text: Text = buf.toString.tt

package decimalFormatters:
given DecimalConverter as java:
given java: DecimalConverter:
def decimalize(double: Double): Text = double.toString.tt

package enumIdentification:
given [EnumType <: reflect.Enum] => EnumType is Identifiable as kebabCase =
given kebabCase: [EnumType <: reflect.Enum] => EnumType is Identifiable =
Identifiable(_.uncamel.kebab, _.unkebab.pascal)

given [EnumType <: reflect.Enum] => EnumType is Identifiable as snakeCase =
given snakeCase: [EnumType <: reflect.Enum] => EnumType is Identifiable =
Identifiable(_.uncamel.snake, _.unsnake.pascal)

given [EnumType <: reflect.Enum] => EnumType is Identifiable as pascalCase =
given pascalCase: [EnumType <: reflect.Enum] => EnumType is Identifiable =
Identifiable(identity(_), identity(_))

given [EnumType <: reflect.Enum] => EnumType is Identifiable as camelCase =
given camelCase: [EnumType <: reflect.Enum] => EnumType is Identifiable =
Identifiable(_.uncamel.camel, _.unsnake.pascal)
2 changes: 1 addition & 1 deletion src/core/gossamer.Cuttable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object Cuttable:
given Text is Cuttable by Regex = (text, regex, limit) =>
text.s.split(regex.pattern.s, limit).nn.map(_.nn.tt).to(List)

given [TextType](using cuttable: TextType is Cuttable by Text) => TextType is Cuttable by Char =
given [TextType] => (cuttable: TextType is Cuttable by Text) => TextType is Cuttable by Char =
(text, delimiter, limit) =>
cuttable.cut(text, delimiter.toString.tt, limit)

Expand Down
2 changes: 1 addition & 1 deletion src/core/gossamer.Presentational.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import vacuous.*
import language.experimental.captureChecking

object Presentational:
given Text is Textual as text:
given text: Text is Textual:
type Show[ValueType] = ValueType is spectacular.Showable
val classTag: ClassTag[Text] = summon[ClassTag[Text]]
def show[ValueType](value: ValueType)(using show: Show[ValueType]): Text = show.text(value)
Expand Down
6 changes: 3 additions & 3 deletions src/test/gossamer.Tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import anticipation.*
import contingency.*
import denominative.*
import hieroglyph.{lower as _, upper as _, *}, charEncoders.utf8, textMetrics.uniform
import larceny.*
//import larceny.*
import probably.*
import rudiments.{where as _, *}
import spectacular.*
Expand Down Expand Up @@ -531,12 +531,12 @@ object Tests extends Suite(t"Gossamer Tests"):

. assert(_ == t"HELLO")

suite(t"Compile errors"):
/*suite(t"Compile errors"):
test(t"Check that Text and String are incompatible"):
demilitarize:
val x: String = Text("text")
. assert(_.head.id == CompileErrorId.TypeMismatch)
. assert(_.head.id == CompileErrorId.TypeMismatch)*/

suite(t"Decimalization tests"):
test(t"Write negative pi"):
Expand Down

0 comments on commit 538fbbd

Please sign in to comment.