Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/gureum/gureum into search…

…_accuracy
  • Loading branch information...
presto95 committed Oct 6, 2019
2 parents bcc9fb1 + ba01bbb commit 14923b42d8b3c5901904ec9452cb8c87c8c7032a
@@ -1110,13 +1110,15 @@
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-OSX/Pods-OSX-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FoundationExtension/FoundationExtension.framework",
"${BUILT_PRODUCTS_DIR}/Fuse/Fuse.framework",
"${BUILT_PRODUCTS_DIR}/SwiftCarbon/SwiftCarbon.framework",
"${BUILT_PRODUCTS_DIR}/SwiftCoreServices/SwiftCoreServices.framework",
"${BUILT_PRODUCTS_DIR}/SwiftIOKit/SwiftIOKit.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FoundationExtension.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Fuse.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftCarbon.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftCoreServices.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftIOKit.framework",
@@ -1211,6 +1213,7 @@
"${PODS_ROOT}/Target Support Files/Pods-OSXTestApp/Pods-OSXTestApp-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FoundationExtension/FoundationExtension.framework",
"${BUILT_PRODUCTS_DIR}/MASShortcut/MASShortcut.framework",
"${BUILT_PRODUCTS_DIR}/Fuse/Fuse.framework",
"${BUILT_PRODUCTS_DIR}/SwiftCarbon/SwiftCarbon.framework",
"${BUILT_PRODUCTS_DIR}/SwiftCoreServices/SwiftCoreServices.framework",
"${BUILT_PRODUCTS_DIR}/SwiftIOKit/SwiftIOKit.framework",
@@ -1219,6 +1222,7 @@
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FoundationExtension.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MASShortcut.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Fuse.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftCarbon.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftCoreServices.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftIOKit.framework",
@@ -103,6 +103,10 @@ sudo gem install xcpretty
가능하면 로그와 `Console.app`을 먼저 사용해보고 디버거가 필요한 경우에만 디버거를 붙여 쓰는 것을 추천합니다.


## 환경설정 테스트

환경설정은 실제로 시스템 환경설정을 열지 않고도, `OSXTestApp` 타겟을 빌드하면 테스트 앱으로도 변경하면서 테스트할 수 있습니다.

## 커밋하기 전에

### 유닛 테스트 수행
@@ -13,11 +13,24 @@ format:
swiftformat OSXCore/ OSX/ GureumTests/ Preferences/ OSXTestApp/

brew-install:
@command -v brew >/dev/null || { echo 'Homebrew is not installed. See https://brew.sh'; exit 1; }
brew install shellcheck swiftformat
@command -v brew >/dev/null || { echo 'Error: Homebrew is not installed. See https://brew.sh'; exit 1; }
@if ! command -v shellcheck >/dev/null; then \
echo 'brew install shellcheck'; \
brew install shellcheck; \
fi
@if ! command -v swiftformat >/dev/null; then \
echo 'brew install swiftformat'; \
brew install swiftformat; \
fi

gem-install:
@echo 'gem install cocoapods xcpretty'
@gem install cocoapods xcpretty || { echo 'gem-install failed. Try sudo make gem-install.'; exit 1; }
@if ! command -v pod >/dev/null; then \
echo 'gem install cocoapods'; \
gem install cocoapods || { echo 'Error: gem-install failed. Try sudo make gem-install.'; exit 1; }; \
fi
@if ! command -v xcpretty >/dev/null; then \
echo 'gem install xcpretty'; \
gem install xcpretty || { echo 'Error: gem-install failed. Try sudo make gem-install.'; exit 1; }; \
fi

.PHONY: all init format brew-install gem-install
@@ -3,8 +3,6 @@
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>org.youknowone.Gureum</string>
</array>
<array/>
</dict>
</plist>
@@ -8,6 +8,7 @@
import Carbon
import Cocoa
import Fuse
import Hangul

let DEBUG_SEARCH_COMPOSER = false
@@ -35,7 +36,7 @@ enum HanjaTable {
/// 한국어로 연결되는 이모지를 모아 놓은 테이블.
static let emojiKorean = HGHanjaTable(contentOfFile: hangulBundle.path(forResource: "emoji_ko", ofType: "txt", inDirectory: "hanja")!)!
/// 로마자로 연결되는 이모지를 모아 놓은 테이블.
static let emoji = HGHanjaTable(contentOfFile: hangulBundle.path(forResource: "emoji", ofType: "txt", inDirectory: "hanja")!)!
static let emoji = try! String(contentsOfFile: hangulBundle.path(forResource: "emoji", ofType: "txt", inDirectory: "hanja")!, encoding: .utf8).components(separatedBy: .newlines)
}

// MARK: - SearchComposer 클래스
@@ -385,20 +386,22 @@ private extension SearchComposer {
} else {
let loweredKeyword = keyword.lowercased() // case insensitive searching
_candidates = []
let fuse = Fuse(threshold: 0.2)
for table in [HanjaTable.emoji] {
dlog(DEBUG_SEARCH_COMPOSER, "DEBUG 3, DelegatedComposer.updateEmojiCandidates() before hanjasByPrefixSearching")
dlog(DEBUG_SEARCH_COMPOSER, "DEBUG 4, DelegatedComposer.updateEmojiCandidates() [keyword: %@]", loweredKeyword)
dlog(DEBUG_SEARCH_COMPOSER, "DEBUG 14, DelegatedComposer.updateEmojiCandidates() %@", HanjaTable.emoji.debugDescription)
let list: HGHanjaList = table.hanjas(byPrefixSearching: loweredKeyword) ?? HGHanjaList()
let searchResult = fuse.search(keyword, in: table)
// change searchResult(index, score, ranges) to candidate(emoticon, comment)
dlog(DEBUG_SEARCH_COMPOSER, "DEBUG 5, DelegatedComposer.updateEmojiCandidates() after hanjasByPrefixSearching")

dlog(DEBUG_SEARCH_COMPOSER, "DEBUG 9, DelegatedComposer.updateEmojiCandidates() count is %d", list.count)
for index in 0 ..< list.count {
let emoticon = list.hanja(at: index)
dlog(DEBUG_SEARCH_COMPOSER, "DEBUG 6, DelegatedComposer.updateEmojiCandidates() %@ %@ %@", list.hanja(at: index).comment, list.hanja(at: index).key, list.hanja(at: index).value)
_candidates!.append(
NSAttributedString(string: emoticon.value as String + ": " + emoticon.comment as String)
)
if searchResult.count <= 0 {
break
}
for result in searchResult {
let emoticonLine: String = table[result.index]
let emoticon: String = String(emoticonLine.split(separator: ":")[1])
let comment: String = String(emoticonLine.split(separator: ":")[0])
_candidates!.append(NSAttributedString(string: emoticon + ": " + comment))
}
}
}
@@ -9,6 +9,7 @@ target 'OSXCore' do
pod 'SwiftIOKit'
pod 'SwiftCarbon'
pod 'SwiftCoreServices'
pod 'Fuse'
end
target 'OSX' do
project 'Gureum.xcodeproj'
@@ -12,6 +12,7 @@ PODS:
- FoundationExtension/FoundationExtensionRC
- FoundationExtension/FoundationExtensionRC (2.0.0):
- cdebug (~> 1.1)
- Fuse (1.2.0)
- MASShortcut (2.4.0)
- SwiftCarbon (0.1.0):
- SwiftCarbon/HIToolbox (= 0.1.0)
@@ -27,6 +28,7 @@ DEPENDENCIES:
- Crashlytics
- Fabric
- FoundationExtension (~> 2.0.0)
- Fuse
- MASShortcut
- SwiftCarbon
- SwiftCoreServices
@@ -38,6 +40,7 @@ SPEC REPOS:
- Crashlytics
- Fabric
- FoundationExtension
- Fuse
- MASShortcut
- SwiftCarbon
- SwiftCoreServices
@@ -48,11 +51,12 @@ SPEC CHECKSUMS:
Crashlytics: 540b7e5f5da5a042647227a5e3ac51d85eed06df
Fabric: 706c8b8098fff96c33c0db69cbf81f9c551d0d74
FoundationExtension: 0c3615327b9d7844ca5f65bfb4dd7563baab197a
Fuse: 287bd95a5c8dbfe6c41af519eaf48856aa1a28f6
MASShortcut: d9e4909e878661cc42877cc9d6efbe638273ab57
SwiftCarbon: c48bbbff6c451022e89c46b85d0e9b44c64ef61b
SwiftCoreServices: e4aebffc7143ff3e06920ecb89654f7c81f9768a
SwiftIOKit: 9dce3dec67e00dc74b95fde86f257aca78239853

PODFILE CHECKSUM: e925c41ce712d2063ff0a1d1979b3aa17c3d7854
PODFILE CHECKSUM: bd16d9e213df73a5a491232ac0d601cc5c52a6ff

COCOAPODS: 1.8.0
@@ -8,7 +8,7 @@
import UIKit

var _UIActivityIndicatorViewAnimatedCounters = Dictionary<UIActivityIndicatorView, Int>()
var _UIActivityIndicatorViewAnimatedCounters = [UIActivityIndicatorView: Int]()

extension UIActivityIndicatorView {
var _animatingCount: Int {
@@ -37,7 +37,7 @@ extension UIActivityIndicatorView {
}
}

var _UIWindowActivityIndicatorViews = Dictionary<UIWindow, UIActivityIndicatorView>()
var _UIWindowActivityIndicatorViews = [UIWindow: UIActivityIndicatorView]()

func UIActivityIndicatorViewForWindow(window: UIWindow) -> UIActivityIndicatorView {
let indicator_ = _UIWindowActivityIndicatorViews[window]
@@ -99,7 +99,7 @@ class LayoutEditorViewController: PreviewViewController, UITableViewDataSource,
var layouts = preferences.layouts
layouts.remove(at: indexPath.row)
preferences.layouts = layouts
let indexPaths: Array<Any> = [indexPath]
let indexPaths: [Any] = [indexPath]
tableView.deleteRows(at: indexPaths as! [IndexPath], with: .top)
case .insert:
assert(indexPath.section == 1)
@@ -56,7 +56,7 @@ class QuickHelperTableViewController: UITableViewController {

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if selectedIndexPaths.contains(indexPath) {
selectedIndexPaths = selectedIndexPaths.filter({ indexPath != $0 })
selectedIndexPaths = selectedIndexPaths.filter { indexPath != $0 }
} else {
selectedIndexPaths.append(indexPath)
}
@@ -108,7 +108,7 @@ class DoneQuickHelperTableViewController: QuickHelperTableViewController {
cell.detailTextLabel!.text = NSLocalizedString(result["left"] as! String, comment: "")
case 2:
cell.textLabel!.text = "오른쪽 보조자판"
let parts = (result["right"] as! Array).map({ NSLocalizedString($0, comment: "") })
let parts = (result["right"] as! Array).map { NSLocalizedString($0, comment: "") }
let text = parts.joined()
cell.detailTextLabel!.text = text.count > 0 ? text : "없음"
case 3:
@@ -17,6 +17,8 @@ class StaticWebViewController: UIViewController {

class func url() -> URL {
assert(false)
let url = URL(string: "")
return url!
}

override func viewDidLoad() {
@@ -49,7 +49,7 @@ class StoreItem {
class Store: NSObject, SKProductsRequestDelegate, SKPaymentTransactionObserver {
let backgroundQueue = DispatchQueue.global(qos: DispatchQoS.QoSClass.background)
var entries: [[String: Any]] = []
var products: Dictionary<String, SKProduct> = [:]
var products: [String: SKProduct] = [:]

override init() {
super.init()
@@ -122,7 +122,6 @@ class Store: NSObject, SKProductsRequestDelegate, SKPaymentTransactionObserver {
print("InAppPurchase SKPaymentTransactionStatePurchasing")
let alertView = UIAlertView(title: "구매를 시도합니다", message: "", delegate: nil, cancelButtonTitle: "cancel", otherButtonTitles: "other...")
alertView.show()
break
/// < 구매 완료
case .purchased:
print("InAppPurchase SKPaymentTransactionStatePurchased")
@@ -19,15 +19,15 @@ class ThemeViewController: PreviewViewController, UITableViewDataSource, UITable

var themePath = preferences.themePath

var entries: Array<Dictionary<String, Any>> = []
var entries: [[String: Any]] = []

func loadEntries() {
let url = NSURL(string: "http://w.youknowone.org/gureum/shop-preview.json")!
guard let data = try? Data(contentsOf: url as URL) else {
return
}

guard let items = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions(rawValue: 0)) as! Array<Dictionary<String, Any>> else {
guard let items = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions(rawValue: 0)) as! [[String: Any]] else {
assert(false)
return
}
@@ -86,7 +86,7 @@ class ThemeViewController: PreviewViewController, UITableViewDataSource, UITable
if entries.count > 0 {
let sub: Any? = entries[section]["items"]
assert(sub != nil)
let items = sub! as! Array<Any>
let items = sub! as! [Any]
return items.count
} else {
return 0
@@ -122,7 +122,7 @@ class ThemeViewController: PreviewViewController, UITableViewDataSource, UITable
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let sub: Any? = entries[indexPath.section]["items"]
assert(sub != nil)
let item = (sub! as! Array<Dictionary<String, String>>)[indexPath.row]
let item = (sub! as! [[String: String]])[indexPath.row]

if let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as UITableViewCell? {
cell.textLabel?.text = item["title"]
@@ -150,7 +150,7 @@ class ThemeViewController: PreviewViewController, UITableViewDataSource, UITable
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let sub: Any? = entries[indexPath.section]["items"]
assert(sub != nil)
let item = (sub as! Array<Dictionary<String, String>>)[indexPath.row]
let item = (sub as! [[String: String]])[indexPath.row]
themePath = item["addr"]!

readyTheme()
@@ -174,23 +174,23 @@ class ThemeViewController: PreviewViewController, UITableViewDataSource, UITable
}

// nested function cause swiftc fault
func collectResources(node: Any!) -> Dictionary<String, Bool> {
func collectResources(node: Any!) -> [String: Bool] {
// println("\(node)")
if node is String {
let str = node as! String
return [str: true]
} else if node is Dictionary<String, Any> {
var resources: Dictionary<String, Bool> = [:]
for subnode in (node as! Dictionary<String, Any>).values {
} else if node is [String: Any] {
var resources: [String: Bool] = [:]
for subnode in (node as! [String: Any]).values {
let collection = collectResources(node: subnode)
for collected in collection.keys {
resources[collected] = true
}
}
return resources
} else if node is Array<Any> {
var resources: Dictionary<String, Bool> = [:]
for subnode in node as! Array<Any> {
} else if node is [Any] {
var resources: [String: Bool] = [:]
for subnode in node as! [Any] {
let collection = collectResources(node: subnode)
for collected in collection.keys {
resources[collected] = true
@@ -260,7 +260,7 @@ extension Theme {

func dumpData() -> [String: String] {
let traitsConfiguration = mainConfiguration["trait"] as! NSDictionary?
var resources = Dictionary<String, String>()
var resources = [String: String]()
assert(traitsConfiguration != nil, "config.json에서 trait 속성을 찾을 수 없습니다.")
for traitFilename in traitsConfiguration!.allValues {
let datastr = encodedDataForFilename(filename: traitFilename as! String)
@@ -80,7 +80,7 @@ class EmoticonKeyboardLayout: KeyboardLayout, UITableViewDataSource, UITableView
var frequencyHistory = preferences.emoticonHistory
lazy var favorites: [String] = self.populateFavorites()
func populateFavorites() -> [String] {
let scores = Array(frequencyMap.keys.map({ ($0, self.frequencyMap[$0]!) }))
let scores = Array(frequencyMap.keys.map { ($0, self.frequencyMap[$0]!) })
let sorted = scores.sorted(by: {
let (text1, score1) = $0
let (text2, score2) = $1
@@ -91,7 +91,7 @@ class EmoticonKeyboardLayout: KeyboardLayout, UITableViewDataSource, UITableView
}
})

var emoticons: [String] = Array(sorted[0 ..< min(sorted.count, 24)].map({ (emoticon: String, _: UInt) -> String in emoticon }))
var emoticons: [String] = Array(sorted[0 ..< min(sorted.count, 24)].map { (emoticon: String, _: UInt) -> String in emoticon })
for emoticon in frequencyHistory as! [String] {
if emoticons.contains(emoticon) {
continue
@@ -203,15 +203,15 @@ class EmoticonKeyboardLayout: KeyboardLayout, UITableViewDataSource, UITableView
}
}

override func helper(helper _: GRKeyboardLayoutHelper, leftButtonsForRow row: Int) -> Array<UIButton> {
override func helper(helper _: GRKeyboardLayoutHelper, leftButtonsForRow row: Int) -> [UIButton] {
if row == 0 {
return []
} else {
return [self.view.nextKeyboardButton] + self.emoticonView.sectionButtons.map({ $0 }) + [self.view.deleteButton]
return [self.view.nextKeyboardButton] + self.emoticonView.sectionButtons.map { $0 } + [self.view.deleteButton]
}
}

override func helper(helper _: GRKeyboardLayoutHelper, rightButtonsForRow _: Int) -> Array<UIButton> {
override func helper(helper _: GRKeyboardLayoutHelper, rightButtonsForRow _: Int) -> [UIButton] {
return []
}

@@ -269,7 +269,7 @@ class EmoticonKeyboardLayout: KeyboardLayout, UITableViewDataSource, UITableView
let section = indexPath.section
if indexPath.row == 0 || indexPath.row == self.tableView(tableView, numberOfRowsInSection: section) - 1 {
let identifier = "margin"
let cell = (tableView.dequeueReusableCell(withIdentifier: identifier)) ?? {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier) ?? {
let cell = UITableViewCell(style: .default, reuseIdentifier: identifier)
cell.backgroundColor = UIColor.clear
return cell
@@ -279,7 +279,7 @@ class EmoticonKeyboardLayout: KeyboardLayout, UITableViewDataSource, UITableView

let identifier = "cell_\(section)"
let numberOfColumns = type(of: self).numbersOfColumns[indexPath.section]
let cell = (tableView.dequeueReusableCell(withIdentifier: identifier)) ?? {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier) ?? {
let cell = UITableViewCell(style: .default, reuseIdentifier: identifier)
cell.backgroundColor = UIColor.clear
for _ in 0 ..< numberOfColumns {
@@ -6,7 +6,7 @@
// Copyright (c) 2014년 youknowone.org. All rights reserved.
//

@import UIKit
@import UIKit;


@class GRInputEffectView;

0 comments on commit 14923b4

Please sign in to comment.
You can’t perform that action at this time.