From 39bc852968abaa30ef02fa0be5ec74970262ffcc Mon Sep 17 00:00:00 2001 From: Jim Wallace <james.wallace@uwaterloo.ca> Date: Thu, 21 Dec 2023 21:57:36 -0500 Subject: [PATCH] Cleaning up for Linux --- Package.resolved | 9 ------- Package.swift | 4 +-- .../SNLPCorpus + Text Processing.swift | 24 ++++++++++++++++- .../SNLPCorpus.swift | 24 ++++++++++++++++- .../SNLPDataItem.swift | 26 ++++++++++++++++--- .../SNLPDictionary.swift | 23 +++++++++++++--- .../SNLPTopicModel.swift | 23 +++++++++++++--- .../1. Data Collection/CSV/CSVDataItem.swift | 2 +- .../5. Topic Model/StubTopicModel.swift | 22 +++++++++++++--- .../Session Network Endpoint Tests.swift | 11 +------- Tests/SwiftNLPTests/SwiftAnnoyTest.swift | 2 +- 11 files changed, 130 insertions(+), 40 deletions(-) diff --git a/Package.resolved b/Package.resolved index a06bb941..349cccf2 100644 --- a/Package.resolved +++ b/Package.resolved @@ -62,15 +62,6 @@ "revision" : "8eeea249ead49f6f8db8e76bf66abce49cc5b856", "version" : "1.0.0" } - }, - { - "identity" : "swiftcsv", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swiftcsv/SwiftCSV.git", - "state" : { - "revision" : "96fa14b92e88e0befdbc8bc31c7c2c9594a30060", - "version" : "0.8.1" - } } ], "version" : 2 diff --git a/Package.swift b/Package.swift index e5c3ed79..c49981ed 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( .package(url: "https://github.com/tsolomko/SWCompression.git", .upToNextMajor(from: "4.8.5")), .package(url: "https://github.com/jbadger3/SwiftAnnoy", .upToNextMajor(from: "1.0.0")), .package(url: "https://github.com/L1MeN9Yu/Elva", .upToNextMajor(from: "2.0.0")), - .package(url: "https://github.com/swiftcsv/SwiftCSV.git", from: "0.8.0"), + //.package(url: "https://github.com/swiftcsv/SwiftCSV.git", from: "0.8.0"), .package(url: "https://github.com/Bersaelor/KDTree", .upToNextMajor(from: "1.4.1")), .package(url: "https://github.com/apple/swift-collections", .upToNextMinor(from: "1.0.0")), //.package(url: "https://github.com/dclelland/Plinth", from: "2.0.0"), @@ -35,7 +35,7 @@ let package = Package( "SWCompression", "SwiftAnnoy", .product(name: "ZSTD", package: "Elva"), - "SwiftCSV", + //"SwiftCSV", "KDTree", .product(name: "Collections", package: "swift-collections"), //"Plinth", diff --git a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus + Text Processing.swift b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus + Text Processing.swift index 9382488e..f3b3971d 100644 --- a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus + Text Processing.swift +++ b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus + Text Processing.swift @@ -1,5 +1,27 @@ -import Foundation +// Copyright (c) 2023 Jim Wallace +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +import Foundation extension SNLPCorpus { static func applyBasicTextProcessing(_ text: String, characterFilters: CharacterSet, tokenFilters: Set<String>) -> [String] { diff --git a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus.swift b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus.swift index 1292f81c..0f04280e 100644 --- a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus.swift +++ b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPCorpus.swift @@ -1,5 +1,27 @@ -import Foundation +// Copyright (c) 2023 Jim Wallace +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +import Foundation protocol SNLPCorpus { diff --git a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDataItem.swift b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDataItem.swift index d70aa852..b79e6fdc 100644 --- a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDataItem.swift +++ b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDataItem.swift @@ -1,8 +1,26 @@ +// Copyright (c) 2023 Jim Wallace +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. -// What's the most basic, common features we need? -// - A date -// - Some text (maybe a bunch, concatenated?) -// - An ID for the entry ... Identifiable means awkwardness for Mac versioning import Foundation public protocol SNLPDataItem: Codable, Equatable, Identifiable { diff --git a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDictionary.swift b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDictionary.swift index 34524790..fcee4dbe 100644 --- a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDictionary.swift +++ b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPDictionary.swift @@ -1,12 +1,27 @@ +// Copyright (c) 2023 Jim Wallace // -// SNLPDictionary.swift -// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: // -// Created by Jim Wallace on 2023-03-09. +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. import Foundation -import NaturalLanguage protocol SNLPDictionary : Codable { diff --git a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPTopicModel.swift b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPTopicModel.swift index 792e35be..47ba50b6 100644 --- a/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPTopicModel.swift +++ b/Sources/SwiftNLP/0. SNLP Internal Protocols/SNLPTopicModel.swift @@ -1,14 +1,29 @@ +// Copyright (c) 2023 Jim Wallace // -// File.swift -// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: // -// Created by Jim Wallace on 2023-04-06. +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. import Foundation - protocol SNLPTopicModel { associatedtype DocumentEncoding diff --git a/Sources/SwiftNLP/1. Data Collection/CSV/CSVDataItem.swift b/Sources/SwiftNLP/1. Data Collection/CSV/CSVDataItem.swift index cf63f39b..fe9f4187 100644 --- a/Sources/SwiftNLP/1. Data Collection/CSV/CSVDataItem.swift +++ b/Sources/SwiftNLP/1. Data Collection/CSV/CSVDataItem.swift @@ -1,5 +1,5 @@ import Foundation -import SwiftCSV +//import SwiftCSV public struct CSVDataItem: SNLPDataItem { diff --git a/Sources/SwiftNLP/5. Topic Model/StubTopicModel.swift b/Sources/SwiftNLP/5. Topic Model/StubTopicModel.swift index 664c3abb..30afc387 100644 --- a/Sources/SwiftNLP/5. Topic Model/StubTopicModel.swift +++ b/Sources/SwiftNLP/5. Topic Model/StubTopicModel.swift @@ -1,9 +1,25 @@ +// Copyright (c) 2023 Jim Wallace // -// File.swift -// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: // -// Created by Jim Wallace on 2023-04-06. +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. import Foundation diff --git a/Tests/SwiftNLPTests/Reddit API/Session Network Endpoint Tests.swift b/Tests/SwiftNLPTests/Reddit API/Session Network Endpoint Tests.swift index 38ddf0ea..4b84750f 100644 --- a/Tests/SwiftNLPTests/Reddit API/Session Network Endpoint Tests.swift +++ b/Tests/SwiftNLPTests/Reddit API/Session Network Endpoint Tests.swift @@ -169,16 +169,7 @@ final class RedditSessionEndpointTest: XCTestCase { // This should return an array of listings, one with original submisison and one with responses. // It's a big thread, so we *should* also get a `more` entry let result = try await client.searchComment(subreddit: "AskReddit", articleID: "7dljcy", showMore: true) - -// for (i, listing) in result.enumerated() { -// print("Listing \(i): \(listing.data.children.count) elements") -// for item in listing.data.children { -// if item.kind == .more { -// print(item) -// } -// } -// } - + XCTAssert(result.count > 0) //XCTAssert(result[1].children.count > 0) } diff --git a/Tests/SwiftNLPTests/SwiftAnnoyTest.swift b/Tests/SwiftNLPTests/SwiftAnnoyTest.swift index 8d05a082..534d7bb2 100644 --- a/Tests/SwiftNLPTests/SwiftAnnoyTest.swift +++ b/Tests/SwiftNLPTests/SwiftAnnoyTest.swift @@ -30,7 +30,7 @@ final class SwiftAnnoyTest: XCTestCase { //print("Initialized corpus in \(totalTime) seconds") corpus.addDocuments(documents: docs) - print(corpus.encodedDocuments) + //print(corpus.encodedDocuments) let dictionary = corpus.dictionary -- GitLab