Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
Later on we will want to restructure how the types are exported, but
that is a bigger effort, so I just added the same workaround to my
modified types as @kustosz used originally in his PR.
  • Loading branch information
radeusgd committed Sep 27, 2022
1 parent 9220a6c commit bf332ed
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 183 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from Standard.Base import all

# TODO Dubious constructor export
from project.Data.Text.Case_Sensitivity.Case_Sensitivity import all
from project.Data.Text.Case_Sensitivity.Case_Sensitivity export all

type Case_Sensitivity
## Represents a case-sensitive comparison mode.
Sensitive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@ Text.find self pattern mode=Regex_Mode.All match_ascii=Nothing case_insensitive=
> Example
Split the text on a regex pattern.

"abc--def==>ghi".split "[-=>]+" Regex_Matcher_Data == ["abc", "def", "ghi"]
"abc--def==>ghi".split "[-=>]+" Regex_Matcher.Regex_Matcher_Data == ["abc", "def", "ghi"]

> Example
Split the text on any whitespace.

'abc def\tghi'.split '\\s+' Regex_Matcher_Data == ["abc", "def", "ghi"]
'abc def\tghi'.split '\\s+' Regex_Matcher.Regex_Matcher_Data == ["abc", "def", "ghi"]
Text.split : Text -> (Text_Matcher | Regex_Matcher) -> Vector.Vector Text
Text.split self delimiter="," matcher=Text_Matcher.Case_Sensitive = if delimiter.is_empty then Error.throw (Illegal_Argument_Error_Data "The delimiter cannot be empty.") else
case Meta.type_of matcher of
Expand Down Expand Up @@ -896,7 +896,7 @@ Text.starts_with self prefix matcher=Text_Matcher.Case_Sensitive = case matcher
Text_Matcher.Case_Sensitive -> Text_Utils.starts_with self prefix
Text_Matcher.Case_Insensitive locale ->
self.take (Text_Sub_Range.First prefix.length) . equals_ignore_case prefix locale=locale
Regex_Matcher_Data _ _ _ _ _ ->
Regex_Matcher.Regex_Matcher_Data _ _ _ _ _ ->
preprocessed_pattern = "\A(?:" + prefix + ")"
compiled_pattern = matcher.compile preprocessed_pattern
match = compiled_pattern.match self Regex_Mode.First
Expand Down Expand Up @@ -931,7 +931,7 @@ Text.ends_with self suffix matcher=Text_Matcher.Case_Sensitive = case matcher of
Text_Matcher.Case_Sensitive -> Text_Utils.ends_with self suffix
Text_Matcher.Case_Insensitive locale ->
self.take (Text_Sub_Range.Last suffix.length) . equals_ignore_case suffix locale=locale
Regex_Matcher_Data _ _ _ _ _ ->
Regex_Matcher.Regex_Matcher_Data _ _ _ _ _ ->
preprocessed_pattern = "(?:" + suffix + ")\z"
compiled_pattern = matcher.compile preprocessed_pattern
match = compiled_pattern.match self Regex_Mode.First
Expand Down Expand Up @@ -993,7 +993,7 @@ Text.contains self term="" matcher=Text_Matcher.Case_Sensitive = case matcher of
Text_Matcher.Case_Sensitive -> Text_Utils.contains self term
Text_Matcher.Case_Insensitive locale ->
Text_Utils.contains_case_insensitive self term locale.java_locale
Regex_Matcher_Data _ _ _ _ _ ->
Regex_Matcher.Regex_Matcher_Data _ _ _ _ _ ->
compiled_pattern = matcher.compile term
match = compiled_pattern.match self Regex_Mode.First
match.is_nothing.not
Expand Down Expand Up @@ -1486,7 +1486,7 @@ Text.location_of_all self term="" matcher=Text_Matcher.Case_Sensitive = if term.
grapheme_spans = Vector.from_polyglot_array <| Text_Utils.span_of_all_case_insensitive self term locale.java_locale
grapheme_spans.map grapheme_span->
Span_Data (Range_Data grapheme_span.grapheme_start grapheme_span.grapheme_end) self
Regex_Matcher_Data _ _ _ _ _ ->
Regex_Matcher.Regex_Matcher_Data _ _ _ _ _ ->
case matcher.compile term . match self Regex_Mode.All of
Nothing -> []
matches -> matches.map m-> m.span 0 . to_grapheme_span
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from Standard.Base import all
from Standard.Base.Data.Text.Matching import match_criteria_implementation

# TODO Dubious constructor export
from project.Data.Text.Regex_Matcher.Regex_Matcher import all
from project.Data.Text.Regex_Matcher.Regex_Matcher export all

## Represents regex matching mode.
type Regex_Matcher
## Regex matching mode.
Expand Down Expand Up @@ -55,7 +59,7 @@ type Regex_Matcher
> Example
Check if the provided name matches a regular expression.

(Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive) . match_single_criterion "Foobar" "f.*" == True
(Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive) . match_single_criterion "Foobar" "f.*" == True
match_single_criterion : Text -> Text -> Boolean
match_single_criterion self name criterion =
self.compile criterion . matches name
Expand Down Expand Up @@ -91,7 +95,7 @@ type Regex_Matcher
> Example
Selects objects matching one of the provided patterns, preserving the input order.

Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Sensitive . match_criteria ["foo", "foobar", "quux", "baz", "Foo"] [".*ba.*", "f.*"] == ["foo", "foobar", "baz"]
Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Sensitive . match_criteria ["foo", "foobar", "quux", "baz", "Foo"] [".*ba.*", "f.*"] == ["foo", "foobar", "baz"]

> Example
Selects pairs matching their first element with the provided criteria and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from Standard.Base import all
from Standard.Base.Data.Text.Matching import match_criteria_implementation

# TODO Dubious constructor export
from project.Data.Text.Text_Matcher.Text_Matcher import all
from project.Data.Text.Text_Matcher.Text_Matcher export all

## Represents exact text matching mode.
type Text_Matcher
## Represents exact text matching mode.
Expand Down Expand Up @@ -57,7 +61,7 @@ type Text_Matcher
> Example
Selects objects matching one of the provided patterns, preserving the input order.

Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Sensitive . match_criteria ["foo", "foobar", "quux", "baz", "Foo"] [".*ba.*", "f.*"] == ["foo", "foobar", "baz"]
Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Sensitive . match_criteria ["foo", "foobar", "quux", "baz", "Foo"] [".*ba.*", "f.*"] == ["foo", "foobar", "baz"]

> Example
Selects pairs matching their first element with the provided criteria and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from Standard.Base import all

# TODO Dubious constructor export
from project.Data.Text.Text_Ordering.Text_Ordering import all
from project.Data.Text.Text_Ordering.Text_Ordering export all

type Text_Ordering
## Specifies the ordering of text values.

Expand Down
2 changes: 1 addition & 1 deletion distribution/lib/Standard/Base/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export project.Data.Text.Regex
export project.Data.Text.Regex.Regex_Mode
export project.Data.Text.Text_Ordering
export project.Data.Text.Text_Matcher
export project.Data.Text.Regex_Matcher
export project.Data.Time.Date
export project.Data.Time.Date_Time
export project.Data.Time.Time_Of_Day
Expand Down Expand Up @@ -106,7 +107,6 @@ from project.Data.Range export all
https://www.pivotaltracker.com/story/show/181309938
from project.Data.Text.Extensions export Text, Line_Ending_Style, Case, Location, Matching_Mode
from project.Data.Text.Matching export No_Matches_Found_Data
from project.Data.Text.Regex_Matcher export Regex_Matcher_Data
from project.Data.Text export all hiding Encoding, Span
from project.Data.Text.Encoding export Encoding, Encoding_Error, Encoding_Error_Data
from project.Data.Text.Span export all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type Table
> Example
Select columns matching a regular expression.

table.select_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))
table.select_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))

> Example
Select the first two columns and the last column, moving the last one to front.
Expand Down Expand Up @@ -184,7 +184,7 @@ type Table
> Example
Remove columns matching a regular expression.

table.remove_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))
table.remove_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))

> Example
Remove the first two columns and the last column.
Expand Down Expand Up @@ -233,7 +233,7 @@ type Table
> Example
Move columns matching a regular expression to front, keeping columns matching "foo.+" before columns matching "b.*".

table.reorder_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))
table.reorder_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))

> Example
Swap the first two columns.
Expand Down
6 changes: 3 additions & 3 deletions distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ type Table
> Example
Select columns matching a regular expression.

table.select_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))
table.select_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))

> Example
Select the first two columns and the last column, moving the last one to front.
Expand Down Expand Up @@ -360,7 +360,7 @@ type Table
> Example
Remove columns matching a regular expression.

table.remove_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))
table.remove_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))

> Example
Remove the first two columns and the last column.
Expand Down Expand Up @@ -409,7 +409,7 @@ type Table
> Example
Move columns matching a regular expression to front, keeping columns matching "foo.+" before columns matching "b.*".

table.reorder_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))
table.reorder_columns (By_Name ["foo.+", "b.*"] (Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive))

> Example
Swap the first two columns.
Expand Down
2 changes: 1 addition & 1 deletion test/Benchmarks/src/Text/Contains.enso
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ main =
Bench.measure (check_all big_random ["AAAAAA"] Text_Matcher) suite_prefix+" exact" 10 10
Bench.measure (check_all big_random ["AAAAAA"] (Text_Matcher Sort_Direction)) suite_prefix+" case-insensitive" 10 10
Bench.measure (check_all big_random ["AAAAAA"] Regex_Matcher) suite_prefix+" exact regex" 10 10
Bench.measure (check_all big_random ["AAAAAA"] (Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive)) suite_prefix+" case-insensitive regex" 10 10
Bench.measure (check_all big_random ["AAAAAA"] (Regex_Matcher.Regex_Matcher_Data case_sensitivity=Case_Sensitivity.Insensitive)) suite_prefix+" case-insensitive regex" 10 10
Bench.measure (check_all big_random ["A.{5000}A"] Regex_Matcher) suite_prefix+" const-width regex" 10 10
Bench.measure (check_all big_random ["AAAAA.*AAAAA"] Regex_Matcher) suite_prefix+" wildcard regex" 10 10

Expand Down
Loading

0 comments on commit bf332ed

Please sign in to comment.