Quantcast
Browsing all 186 articles
Browse latest View live

Sorting alphanumeric strings

Say I havestrings = {"a16", "b22", "a8", "c1", "b18", "b2", "a1"};Sort@strings gives {"a1", "a16", "a8", "b18", "b2", "b22", "c1"}, but I'd like to obtain {"a1", "a8", "a16", "b2", "b18", "b22", "c1"}....

View Article


Longest Repeated Substring

Is there a solution in Mathematica to the problem of finding the longest substring of a sequence that occurs at least twice.For example {1, 2, 3, 4, 5, 2, 3} has the solution {2,3} or "ABCDEDEFDEFA"...

View Article


How do I remove parts of this data?

The data:{{9.99758, 0}, {"", ""}, {10.0178, -21.7137}, {"", ""}, {10.038, 28.5723}, {"", ""}, {10.0582, 0.52409}, {"", ""}, {10.0784, 21.7378}, {"", ""}, {10.0987, 0}, {"", ""},...}I need to remove the...

View Article

Image may be NSFW.
Clik here to view.

How to train custom named entity recognition?

Version 12 has basic NER support for some entities, but how does one recognize a custom entity?For example, I want to parse text describing products, and parse out three entities: prices, size, and...

View Article

Modern topic modeling?

This question was asked in 2014: How to perform document classification (i.e. extracting topics from text)?At the time user @V.E. gave a great little tutorial on LDA, but today, there's still no...

View Article


How to use `StringJoin` in the given example?

Is there a way to use StringJoin to go from: {{abc, 0000}, {def, 1111}} To{{abc_0000},{def_1111}}I've been trying to use Map and MapThread with StringJoin but have failed.

View Article

Delete strings: {name, John, John Doe, Doe} to {name, John Doe}

I am not very familiar with coding and I am trying to solve the following:Input:{name, John, John Doe, Doe}Output:{name, John Doe}So, it should delete {John, Doe} only if there is a string which...

View Article

Merging certain list elements

I have a list of strings, some of which are all upper case, and some mixed upper and lower, and some are digits with commas:lis = {"ABC","Abc","Def","1","DEF","Ghi","Jkl","MNO","1,"}I would like to...

View Article


From string to number

I have data such as, {{[Part(33.0, 34.0), Part(33.0, 34.0), Part(31.0, 32.0), Part(30.0, 32.0), Part(29.0, 32.0), Part(28.0, 29.0), Part(28.0, 29.0)]}}as text data.I want to get number list of {{33.0,...

View Article


Replace number in string with ? and /;

I am trying to make the following:StringReplace[{"A4", "A#3"}, {"A" ~~ x_ -> "B" ~~ x}]This should replace A4 by B4 but leave A#3 untouched. How can I do that? I tried to use ? and /; with a test...

View Article

Multiple calculations in a condition

I want to add and subtract 3 from a list.pos = {82,84}If[# > 3, (# - 3) && (# + 3)] & /@ posthe output I want:{79,85,81,87}the output I get:{79 && 85, 81 && 87}

View Article

Manipulation of two lists of strings and integers

I have the following lists: l1 = {{"letter.a.a", "1"}, {"letter.b.b", "1"}, {"letter.c.c", "1"}, {"letter.d.d", "1"}, {"letter.e.e", "1"}, {"letter.f.f", "1"}};l2 = {{"f", 10}, {"c", 9}, {"e", 8},...

View Article

Creating rule-based sublists

I have a list each element of which consists of a list containing two strings and two integers:lis = {{"ab", 2, "c", 3}, {"d", 3, "e", 4}, {"ac", 5, "f", 6}, {"c", 7, "d", 8}, {"ad", 9, "c", 10}}I...

View Article


Extract doi from a text string

I have a large list with bibliometric information including the doi like this example:stringdata = {{"name surname, 2207, journal name, vol5, p1233, doi 10.1016/j.enpol.2125.13.027"}, {"name surname,...

View Article

Delete Characters from a list

I have a list which contains multiple words and unsupported characters as well :for eg:{é, â, ê, î, ô, û, c, re, be}I want to remove all of the above characters from a list without creating another...

View Article


Unexplained Error "StringJoin: String expected at position 1 in #1

I have a list genus, containing the list of genus group names for some fishes I work on derived from a column of imported data:genus = tempData2[[All,2]] (* here explicitly specifying just the 4 of...

View Article

Finding words that start and end with same letter

Why does this code run too slow?SameStartEndWords[char_String] := Table[If[{First[Characters[WordList[][[i]]]]} == Characters[char] && {Last[Characters[WordList[][[i]]]]} == Characters[char],...

View Article


Extract strings containing digit characters with StringCases

I have a large string like this:string = {"text, 1998, TEXTDATA, text, 2007, NEXTTEXTDATA"};Now I want to extract TEXTDATA and NEXTTEXTDATA. I tried to use StringCases and Shortestin combination with...

View Article

List rearrangment with joining of strings

I have a list of strings:lis = {{"a","b","x"},{"d","e","y"},{"a","b","z"},{"d","c","x"},{"a","b","w"}}I would like to use StringJoin on the last elements where initial elements are the same to...

View Article

Deletion of string characters by rule

This seems simple:Givenlis = {"abcd12efcdef"}I would like to delete all instances of "ef" when it directly follows a digit character, to give:res = {"abcd12cdef"}

View Article
Browsing all 186 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>