phpSyllable
phpSyllable copied to clipboard
Split sentence into array of arrays of syllables of each word
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"
)
);
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.
Yeah, sure
How do I get write permission?
Just submit a pull request from your forked repository through Github.
I've made a function that works without symbols now, but I would probably need some help to make it work with symbols
I also added a testSplitWords() function in SyllableTest.php
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.
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.
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?
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.
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?
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.
Is this the same as an SSH key or deploy key?
Yes, the SSH key
I've created a pull request now 😄
$syllables = explode('-', $string);
That doesn't take into account word boundaries or hyphens already in the text.
PR #30 is probably related to related to this issue. The PR had been approved but not merged: is there anything missing?
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.
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