Giter VIP home page Giter VIP logo

Comments (10)

gagolews avatar gagolews commented on May 27, 2024

stri_locate_all_class() DONE in commit 7037202

Examples:

> stri_locate_all_class("    xxx\n\t \v   \n", stri_char_getpropertyid("WHITE_SPACE"))
[[1]]
     start end
[1,]     1   4
[2,]     8  15

> stri_locate_all_class(
+     c("abc", "a\u0105b", "a1B2c3", "1\u01052b3C", "123"),
+     stri_char_getcategoryid("L"))
[[1]]
     start end
[1,]     1   3

[[2]]
     start end
[1,]     1   3

[[3]]
     start end
[1,]     1   1
[2,]     3   3
[3,]     5   5

[[4]]
     start end
[1,]     2   2
[2,]     4   4
[3,]     6   6

[[5]]
     start end

> stri_locate_all_class(
+     c("abc", "a\u0105b", "a1B2c3", "1\u01052b3C", "123"),
+     stri_char_getcategoryid("Ll"))
[[1]]
     start end
[1,]     1   3

[[2]]
     start end
[1,]     1   3

[[3]]
     start end
[1,]     1   1
[2,]     5   5

[[4]]
     start end
[1,]     2   2
[2,]     4   4

[[5]]
     start end

from stringi.

gagolews avatar gagolews commented on May 27, 2024

UPDATED stri_locate_all_class() in commit 1073566

Added complement classes option, e.g. ^WHITE_SPACE == not a whitespace character, ^Lu == not an upper-case letter, etc.

Examples:

> stri_locate_all_class(
      c("abc", "a\u0105b", "a1B2c3", "1\u01052b3C", "123"),
      stri_char_getcategoryid("^L"))
[[1]]
     start end

[[2]]
     start end

[[3]]
     start end
[1,]     2   2
[2,]     4   4
[3,]     6   6

[[4]]
     start end
[1,]     1   1
[2,]     3   3
[3,]     5   5

[[5]]
     start end
[1,]     1   3


> stri_locate_all_class("    xxx\n\t \v   \n", stri_char_getpropertyid("^WHITE_SPACE"))
[[1]]
     start end
[1,]     5   7

from stringi.

gagolews avatar gagolews commented on May 27, 2024

*_first_* and *_last_* added in commit 7eb62a5

from stringi.

bartektartanus avatar bartektartanus commented on May 27, 2024

Why stri_locate_all_class returns empty matrix when there is no match and stri_locate_first/last_class returs NA?

from stringi.

gagolews avatar gagolews commented on May 27, 2024

Yep, this should be NA, NA.
Fixed in commit e652434

We now have:

> stri_locate_all_class(
+     c("abc", "a\u0105b", "a1B2c3", "1\u01052b3C", "123"),
+     stri_char_getcategoryid("^L"))
[[1]]
     start end
[1,]    NA  NA

[[2]]
     start end
[1,]    NA  NA

[[3]]
     start end
[1,]     2   2
[2,]     4   4
[3,]     6   6

[[4]]
     start end
[1,]     1   1
[2,]     3   3
[3,]     5   5

[[5]]
     start end
[1,]     1   3

from stringi.

bartektartanus avatar bartektartanus commented on May 27, 2024

stri_locate_all_class("",stri_char_getpropertyid("^WHITE_SPACE")) returns empty matrix and this also should be NA NA, right?
stri_locate_first_class("",stri_char_getpropertyid("^WHITE_SPACE")) == NA , last also working good.

DONE in commit c9467e6

from stringi.

bartektartanus avatar bartektartanus commented on May 27, 2024

stri_locate_all_class(NA, stri_char_getpropertyid("^WHITE_SPACE")) causes a fatal error
It works fine with e.g. c(NA, "a") or c(NA_character_, 0) but single NA crashes RStudio...

from stringi.

gagolews avatar gagolews commented on May 27, 2024

Fixed @ ba56c33
Now stri_locate_all_class(NA, stri_char_getpropertyid("^WHITE_SPACE")) returns (NA, NA)

from stringi.

gagolews avatar gagolews commented on May 27, 2024

New version of first & last @ 574c1a0
Still to be done: all
Use StriContainerUTF8 & new charclass definitions

from stringi.

gagolews avatar gagolews commented on May 27, 2024

ALL done in dff176a

from stringi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.