-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Sources/EeveeSpotify/Models/Extensions/StirngArray+Extension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Foundation | ||
import NaturalLanguage | ||
|
||
extension Array where Element == String { | ||
var canBeRomanized: Bool { | ||
var languageList: [NLLanguage] = [] | ||
|
||
for line in self { | ||
if let language = NLLanguageRecognizer.dominantLanguage(for: line) { | ||
languageList.append(language) | ||
} | ||
} | ||
|
||
let canBeRomanizedLanguageCount = languageList.filter { | ||
[.japanese, .korean, .simplifiedChinese, .traditionalChinese].contains($0) | ||
}.count | ||
|
||
return Double(canBeRomanizedLanguageCount) / Double(languageList.count) > 0.15 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters