@@ -34,7 +34,8 @@ public struct Analysis: Hashable {
3434 sentences = input
3535 . replacingOccurrences ( of: " ! " , with: " ! \n " )
3636 . replacingOccurrences ( of: " . " , with: " . \n " )
37- . replacingOccurrences ( of: " ? " , with: " ? \n " ) . lines
37+ . replacingOccurrences ( of: " ? " , with: " ? \n " )
38+ . lines
3839 . filter { !$0. trimmingCharacters ( in: . whitespaces) . isEmpty }
3940 words = input
4041 . split ( separator: " " )
@@ -44,7 +45,7 @@ public struct Analysis: Hashable {
4445
4546 /// Returns the sentence count of the `input`.
4647 public func sentenceCount( ) -> Int {
47- return sentences. count
48+ sentences. count
4849 }
4950
5051 /// Returns the word count of the `input`.
@@ -62,7 +63,7 @@ public struct Analysis: Hashable {
6263
6364 /// Returns the total amount of syllables of the `input`.
6465 public func syllableCount( ) -> Int {
65- return words
66+ words
6667 . map { $0. syllables }
6768 . reduce ( 0 , + )
6869 }
@@ -105,7 +106,7 @@ public struct Analysis: Hashable {
105106 /// - Returns: A `Dictionary` containing the words and their
106107 /// occurence.
107108 public func wordOccurrences( caseSensitive: Bool = false ) -> [ String : Int ] {
108- return _wordOccurrences ( caseSensitive: caseSensitive)
109+ _wordOccurrences ( caseSensitive: caseSensitive)
109110 }
110111
111112 /// Returns the character occurrences of the `input`.
@@ -117,7 +118,7 @@ public struct Analysis: Hashable {
117118 /// - Returns: A `Dictionary` containing the characters and their
118119 /// occurence.
119120 public func characterOccurences( caseSensitive: Bool = false ) -> [ Character : Int ] {
120- return _characterOccurences ( caseSensitive: caseSensitive)
121+ _characterOccurences ( caseSensitive: caseSensitive)
121122 }
122123
123124 /// Returns the amount of occurrences of the specified word.
@@ -169,7 +170,10 @@ public struct Analysis: Hashable {
169170 of word: String ,
170171 caseSensitive: Bool = false
171172 ) -> Percentage {
172- return Double ( occurrences ( of: word, caseSensitive: caseSensitive) ) / Double( wordCount ( ) ) * 100.0
173+ Double ( occurrences (
174+ of: word,
175+ caseSensitive: caseSensitive
176+ ) ) / Double( wordCount ( ) ) * 100.0
173177 }
174178
175179 /// Returns the frequency of the specified `Character`.
@@ -187,7 +191,12 @@ public struct Analysis: Hashable {
187191 caseSensitive: Bool = false ,
188192 includingSpaces: Bool = true
189193 ) -> Percentage {
190- return Double ( occurrences ( of: character, caseSensitive: caseSensitive) ) / Double( characterCount ( includingSpaces: includingSpaces) ) * 100.0
194+ Double ( occurrences (
195+ of: character,
196+ caseSensitive: caseSensitive
197+ ) ) / Double( characterCount (
198+ includingSpaces: includingSpaces
199+ ) ) * 100.0
191200 }
192201
193202 /// Returns the average characters of the specified `LengthOption`.
@@ -209,49 +218,49 @@ public struct Analysis: Hashable {
209218
210219 /// Returns the average words per sentence.
211220 public var averageWordsPerSentence : Double {
212- return Double ( wordCount ( ) ) / Double( sentenceCount ( ) )
221+ Double ( wordCount ( ) ) / Double( sentenceCount ( ) )
213222 }
214223
215224 private var _wordsPerSentences : Double {
216- return Double ( wordCount ( ) ) / Double( sentenceCount ( ) )
225+ Double ( wordCount ( ) ) / Double( sentenceCount ( ) )
217226 }
218227
219228 private var _syllablesPerWords : Double {
220- return Double ( syllableCount ( ) ) / Double( wordCount ( ) )
229+ Double ( syllableCount ( ) ) / Double( wordCount ( ) )
221230 }
222231
223232 /// Returns the Flesch reading ease score.
224233 ///
225234 /// - Note: https://en.wikipedia.org/wiki/Flesch–Kincaid_readability_tests#Flesch_reading_ease
226235 public func fleschReadingEase( ) -> Percentage {
227- return 206.835 - 1.015 * _wordsPerSentences - 84.6 * _syllablesPerWords
236+ 206.835 - 1.015 * _wordsPerSentences - 84.6 * _syllablesPerWords
228237 }
229238
230239 /// Returns the Flesch-Kincaid grade level.
231240 ///
232241 /// - Note: https://en.wikipedia.org/wiki/Flesch–Kincaid_readability_tests#Flesch.E2.80.93Kincaid_grade_level
233242 public func fleschKincaidGradeLevel( ) -> Grade {
234- return 0.39 * _wordsPerSentences + 11.8 * _syllablesPerWords - 15.59
243+ 0.39 * _wordsPerSentences + 11.8 * _syllablesPerWords - 15.59
235244 }
236245}
237246
238247extension Analysis : Comparable {
239248
240249 public static func < ( lhs: Analysis , rhs: Analysis ) -> Bool {
241- return lhs. input < rhs. input
250+ lhs. input < rhs. input
242251 }
243252}
244253
245254extension Analysis : CustomStringConvertible , CustomDebugStringConvertible {
246255
247256 /// A textual representation of this instance.
248257 public var description : String {
249- return " Analysis( \" \( input) \" ) "
258+ " Analysis( \" \( input) \" ) "
250259 }
251260
252261 /// A representation of the string that is suitable for debugging.
253262 public var debugDescription : String {
254- return dump ( description)
263+ dump ( description)
255264 }
256265}
257266
0 commit comments