0

Is there a way to have wiki display extracts in an array of sentences?

Or does anyone have any ideas other than using string.split(".") to parse? There are cases where the sentence may include a . and I don't want to split if it occurs mid-sentence.

For example, "The Eagles were No. 1 in the U.S. in 1970" would be split into 4 sentences using str.split(), and that's not what I want.

Wiki must have some sort of determination of what defines a sentence as it works when you limit the number of existence in a call (they don't break a sentence on an in-line period). Is there a way to get them individually?

Looking for a solution in JavaScript to parse a JSON excerpt string.

M. Stange
  • 1
  • 3
  • Possible duplicate of [How to break up a paragraph by sentences in Python](https://stackoverflow.com/questions/9474395/how-to-break-up-a-paragraph-by-sentences-in-python) – Zach Gates Sep 03 '17 at 19:30

1 Answers1

0

I ended up figuring out a work-around. Using exsentences, I made 10 calls, each with one more sentence than the previous call. I stored the results of each call in an array. So when the 10 calls were complete, I had 10 strings, ranging from one sentence in position 0, up to 10 sentences in the 9th position. Then I just iterated through the array, from 0 to length - 2, subtracting the string in the current position from the string at position [i + 1] (with string[i + 1].slice(string[i].length)), to get the nth string.

M. Stange
  • 1
  • 3