phpSyllable icon indicating copy to clipboard operation
phpSyllable copied to clipboard

Split sentence into array of arrays of syllables of each word

Open Vicedivic opened this issue 5 years ago • 16 comments

Hi Van der Lee,

Is it possible for any of your functions to return an array of arrays of syllables of each word?

Example: "I am working". Output:

array(

    0 => array(

        0 => "I"

    ), 

    1 => array(

        0 => "am"

    ), 

    2 => array(

        0 => "work", 

        1 => "ing"

    )

);

Vicedivic avatar Dec 01 '18 08:12 Vicedivic

Good idea, but currently not available.

It should be quite possible to add a splitWords(string $text) method that outputs an array of split words. Punctuation, numbers, spacing and other non-words would (optionally) have to appear in their own root elements, but that shouldn't be much of a problem.

If you'd like to contribute such a method, it would be highly appreciated. Otherwise it might take a while for me to get to it, as I'm currently focussing on different projects.

vanderlee avatar Dec 03 '18 19:12 vanderlee

Yeah, sure

Vicedivic avatar Dec 24 '18 15:12 Vicedivic

How do I get write permission?

Vicedivic avatar Dec 24 '18 15:12 Vicedivic

Just submit a pull request from your forked repository through Github.

vanderlee avatar Dec 25 '18 07:12 vanderlee

I've made a function that works without symbols now, but I would probably need some help to make it work with symbols

Vicedivic avatar Dec 26 '18 16:12 Vicedivic

I also added a testSplitWords() function in SyllableTest.php

Vicedivic avatar Dec 26 '18 16:12 Vicedivic

When I try to push the changes to my fork, it says that I don't have permission to do that:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Vicedivic avatar Dec 26 '18 17:12 Vicedivic

Thanks for the effort! The error is probably either a wrong repository name (you have to push to your own fork, not this main repository) or you have not set your public key (I'm assuming this is not the case, considering what you wrote earlier).

Please let me know if this is getting too much work for you, and we could just copy+paste the code but if you want to contribute to other github projects in the future, the process will be the same.

vanderlee avatar Dec 26 '18 17:12 vanderlee

I haven't worked that much with Git, so I would like to learn how the process works 😄 I just have to understand the process: So I start by pushing the changes to my own fork and then create a pull request to your repository? Ps: I haven't created a public key, could that be the case?

Vicedivic avatar Dec 26 '18 17:12 Vicedivic

Exactly right! With Git, you basically only work directly with your own repository and create pull requests. Github manages the pull requests (PR's) and makes it easy to work this way.

vanderlee avatar Dec 26 '18 17:12 vanderlee

So the only problem is that I don't have permission to push to my own fork. Does this have anything to do with the public key that I haven't set?

Vicedivic avatar Dec 26 '18 19:12 Vicedivic

Very likely. You'll need to set up a private/public key pair, install the private key locally and upload the public key pair to github.

vanderlee avatar Dec 26 '18 19:12 vanderlee

Is this the same as an SSH key or deploy key?

Vicedivic avatar Dec 26 '18 19:12 Vicedivic

Yes, the SSH key

vanderlee avatar Dec 26 '18 19:12 vanderlee

I've created a pull request now 😄

Vicedivic avatar Dec 26 '18 20:12 Vicedivic

$syllables = explode('-', $string);

That doesn't take into account word boundaries or hyphens already in the text.

vanderlee avatar Dec 28 '18 15:12 vanderlee

PR #30 is probably related to related to this issue. The PR had been approved but not merged: is there anything missing?

alexander-nitsche avatar Mar 23 '23 07:03 alexander-nitsche

PR #30 has some merge conflicts. I'm pretty short on time at the moment but will try to take a look at it next week.

vanderlee avatar Mar 23 '23 10:03 vanderlee

Hi @Vicedivic ,

to understand your use case in general and specifically: What do you expect should be returned by splitWords(string $text) for the text "Redundant, punctuation..."? This:

[
  ['Re', 'dun', 'dant'],
  [', '],
  ['punc', 'tu', 'a', 'tion'],
  ['...'],
],

?

How should punctuations be handled?

Greetings Alex

alexander-nitsche avatar Apr 17 '23 11:04 alexander-nitsche