Timeline for String Split a phrase into sentences
Current License: CC BY-SA 4.0
32 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 4, 2020 at 10:43 | vote | accept | Nick Stavrou | ||
Jan 3, 2020 at 17:41 | answer | added | Heslacher | timeline score: 2 | |
Jan 3, 2020 at 12:15 | history | edited | Nick Stavrou | CC BY-SA 4.0 |
added 33 characters in body
|
Jan 3, 2020 at 12:12 | history | edited | Heslacher |
edited tags
|
|
Jan 3, 2020 at 12:11 | comment | added | Manos Kolaitis |
Just add Cast<Match>() and it works ``` Dictionary<Match, string> dic = matches.Cast<Match>().Zip(sentences, (x, y) => new { Key = x, Value = y }).ToDictionary(x => x.Key, y => y.Value); ```
|
|
Jan 3, 2020 at 12:03 | history | reopened | Vogel612 | ||
Jan 3, 2020 at 12:03 | comment | added | Vogel612 | Alright, while I don't have a windows at hand, I was able to verify the code as posted works when running it against dotnet core 3.0.100 when targeting netcoreapp3.0. As such I have reopened the question | |
Jan 3, 2020 at 12:00 | comment | added | Nick Stavrou |
@Vogel612 Sure i understand. I am using Console App(.Net Core) in Visual Studio 2019 and the only dependencies i am having is Microsoft.NetCore.App and the targeting framework is 4.7.2
|
|
Jan 3, 2020 at 11:52 | comment | added | Vogel612 |
As it stands, the code as presented looks like it can't quite work as intended, notably how the sentences array is constructed would not produce the results outlined as target results. Additionally there is some ambiguity around the use of the Zip extension method that should be definitively resolved before this code can be reviewed. As such I have closed this question for now until the code for review is verified to be working as expected. Thanks for understanding
|
|
Jan 3, 2020 at 11:50 | history | closed |
user33306 πάντα ῥεῖ Linny Vogel612 |
Not suitable for this site | |
Jan 3, 2020 at 11:36 | comment | added | Nick Stavrou |
@Heslacher i added the matches.Cast<Match>().Zip... also but still it needs this using System.Linq; in order to work. can we talk somehow in a chat and don't fill the post with comments if thats ok with you?
|
|
Jan 3, 2020 at 11:27 | comment | added | Nick Stavrou |
@Heslacher i did copy-paste my code to a new console app and i just added this using System.Linq; and it works the same. Sorry but i can not understand the problem with Zip
|
|
Jan 3, 2020 at 5:07 | comment | added | Heslacher |
In order to review your code the question needs to be on topic which means your code needs to work. We just want to help you making your question on topic. Zip is an extension method taking IEnumerable<T> but MatchCollection only implements IEnumerable . I would like to suggest that you create a new console project pasting your posted code and see what your IDE tells you about the Zip() method.
|
|
Jan 2, 2020 at 22:24 | comment | added | Nick Stavrou |
The one thing i do not understand is that i posted this code on this particular community in order to get my code reviewed and hope to get better solution and better explanation for my future coding style. Even though my code is being criticized about every little bit of things expert coders find. I do accept every criticism for the code i produced but that's not the point i believe in this StackExchange site. I do not hunt score or badges i just want to be a better coder. Even with Cast or not this code runs and it produces the output i provided.
|
|
Jan 2, 2020 at 22:02 | comment | added | user33306 |
matches is a MatchCollection not a Dictionary . No version of MatchCollection contains a Zip method. It can't work as it is. As @Heslacher pointed out it only works with the added Cast method.
|
|
Jan 2, 2020 at 21:34 | comment | added | Nick Stavrou | Framework is 4.7.2 | |
Jan 2, 2020 at 21:25 | history | edited | Nick Stavrou | CC BY-SA 4.0 |
edited title
|
Jan 2, 2020 at 21:20 | comment | added | Nick Stavrou |
@tinstaafl how do you say it doesn't work? i had it run ,the console app, several times and i got the output i provided. As you can see in the phrase it has some keys that are the same. Dictionary contains Zip not the MatchCollection
|
|
Jan 2, 2020 at 16:56 | comment | added | Heslacher |
Well, maybe it isn't that strange because the key is a Match which is different for each Match in the MatchCollection .
|
|
Jan 2, 2020 at 16:55 | review | Close votes | |||
Jan 3, 2020 at 11:55 | |||||
Jan 2, 2020 at 16:53 | comment | added | Heslacher |
@tinstaafl good catch. Using matches.Cast<Match>().Zip... will succeed without an error, and the dictionary has duplicated keys, thats just strange!
|
|
Jan 2, 2020 at 16:31 | comment | added | user33306 |
This code doesn't seem to work. It creates an error when compiling with Framework 4.8. MatchCollection doesn't contain a Zip method.
|
|
Jan 2, 2020 at 15:44 | history | edited | Nick Stavrou | CC BY-SA 4.0 |
added 600 characters in body
|
Jan 2, 2020 at 15:38 | history | edited | Nick Stavrou | CC BY-SA 4.0 |
added 376 characters in body
|
Jan 2, 2020 at 15:30 | review | Close votes | |||
Jan 2, 2020 at 15:45 | |||||
Jan 2, 2020 at 15:16 | history | edited | Nick Stavrou | CC BY-SA 4.0 |
added 20 characters in body
|
Jan 2, 2020 at 15:11 | comment | added | Nick Stavrou | Yes i did copy it from the IDE.. first i split the phrase into words. then with stringbuilder and the regex i made it like sentence, then i added to another array. I do not have experience with C# and thats why i wonder if this is ok | |
Jan 2, 2020 at 15:09 | comment | added | Heslacher |
Did you copy the code directly from your IDE? I am asking because in the first loop the whole if..else..if..else seems senseless because in each branch the code is doing the exactly same thing.
|
|
Jan 2, 2020 at 15:07 | history | edited | Nick Stavrou | CC BY-SA 4.0 |
added 25 characters in body
|
Jan 2, 2020 at 14:59 | history | edited | Nick Stavrou | CC BY-SA 4.0 |
deleted 14 characters in body
|
Jan 2, 2020 at 14:55 | review | First posts | |||
Jan 2, 2020 at 15:12 | |||||
Jan 2, 2020 at 14:54 | history | asked | Nick Stavrou | CC BY-SA 4.0 |