Skip to content

Commit

Permalink
fix: lyrics language identification. this will affect Chinese convers…
Browse files Browse the repository at this point in the history
…ion and Japanese Furigana
  • Loading branch information
ddddxxx committed Oct 4, 2020
1 parent a790b8d commit aba9c45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion LyricsX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@
repositoryURL = "https://github.com/ddddxxx/SwiftCF.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.1.3;
minimumVersion = 0.1.4;
};
};
BB350ABC23D0613D00500146 /* XCRemoteSwiftPackageReference "CXExtensions" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
"repositoryURL": "https://github.com/ddddxxx/SwiftCF.git",
"state": {
"branch": null,
"revision": "efb0309d747cc0d0c288859cbb637947860e4a2e",
"version": "0.1.3"
"revision": "de40c892f92eaf043ac795ed1a04e2a9ecea0d9c",
"version": "0.1.4"
}
},
{
Expand Down
19 changes: 7 additions & 12 deletions LyricsX/Component/Lyrics+Language.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,16 @@ private extension NSCountedSet {
extension Lyrics {

func recognizeLanguage() {
let lyricsLanguageSet = NSCountedSet()
let translationLanguageSet = NSCountedSet()
var lyricsContent = ""
var translationContent = ""
for line in lines {
if let lan = (line.content as NSString).dominantLanguage {
lyricsLanguageSet.add(lan)
lyricsContent += line.content
if let trans = line.attachments.translation() {
translationContent += trans
}
if let trans = line.attachments.translation(),
let transLan = (trans as NSString).dominantLanguage {
translationLanguageSet.add(transLan)
}
}
if let lan = lyricsLanguageSet.mostFrequentElement as! String? {
metadata.language = lan
}
if let transLan = translationLanguageSet.mostFrequentElement as! String? {
metadata.language = (lyricsContent as NSString).dominantLanguage
if let transLan = (translationContent as NSString).dominantLanguage {
let tag = LyricsLine.Attachments.Tag.translation(languageCode: transLan)
guard !metadata.attachmentTags.contains(tag) else {
return
Expand Down
4 changes: 2 additions & 2 deletions LyricsX/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<key>CFBundleShortVersionString</key>
<string>1.5.6</string>
<key>CFBundleVersion</key>
<string>2316</string>
<string>2322</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand All @@ -58,7 +58,7 @@
<key>LSUIElement</key>
<true/>
<key>LX_BUILD_TIME</key>
<integer>1601798683</integer>
<integer>1601804126</integer>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
Expand Down

0 comments on commit aba9c45

Please sign in to comment.