Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Curio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jim Wallace
Curio
Commits
43762051
Commit
43762051
authored
1 year ago
by
Jim Wallace
Browse files
Options
Downloads
Patches
Plain Diff
Removed SWCompression
parent
667da65b
No related branches found
No related tags found
No related merge requests found
Pipeline
#108418
passed with warnings
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Package.resolved
+0
-18
0 additions, 18 deletions
Package.resolved
Package.swift
+2
-2
2 additions, 2 deletions
Package.swift
Sources/SwiftNLP/1. Data Collection/Legacy/20 Newsgroups.swift
+66
-50
66 additions, 50 deletions
...es/SwiftNLP/1. Data Collection/Legacy/20 Newsgroups.swift
with
68 additions
and
70 deletions
Package.resolved
+
0
−
18
View file @
43762051
{
"pins" : [
{
"identity" : "bitbytedata",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tsolomko/BitByteData",
"state" : {
"revision" : "b4b41619522aacd7aae7b02fa8360833e796a03d",
"version" : "2.0.2"
}
},
{
"identity" : "elva",
"kind" : "remoteSourceControl",
...
...
@@ -36,15 +27,6 @@
"version" : "2.3.2"
}
},
{
"identity" : "swcompression",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tsolomko/SWCompression.git",
"state" : {
"revision" : "cd39ca0a3b269173bab06f68b182b72fa690765c",
"version" : "4.8.5"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
...
...
This diff is collapsed.
Click to expand it.
Package.swift
+
2
−
2
View file @
43762051
...
...
@@ -15,7 +15,7 @@ let package = Package(
],
dependencies
:
[
.
package
(
url
:
"https://github.com/Jounce/Surge.git"
,
.
upToNextMajor
(
from
:
"2.3.2"
)),
.
package
(
url
:
"https://github.com/tsolomko/SWCompression.git"
,
.
upToNextMajor
(
from
:
"4.8.5"
)),
//
.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"),
...
...
@@ -32,7 +32,7 @@ let package = Package(
name
:
"SwiftNLP"
,
dependencies
:
[
"Surge"
,
"SWCompression"
,
//
"SWCompression",
"SwiftAnnoy"
,
.
product
(
name
:
"ZSTD"
,
package
:
"Elva"
),
//"SwiftCSV",
...
...
This diff is collapsed.
Click to expand it.
Sources/SwiftNLP/1. Data Collection/Legacy/20 Newsgroups.swift
+
66
−
50
View file @
43762051
// 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-05-29.
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
import
Foundation
import
SWCompression
@inlinable
func
downloadData
(
from
url
:
URL
)
async
throws
->
Data
{
let
(
data
,
_
)
=
try
await
URLSession
.
shared
.
data
(
from
:
url
)
return
data
}
func
download20Newsgroups
()
async
->
[
String
]
{
let
url
=
URL
(
string
:
"http://qwone.com/~jason/20Newsgroups/20news-18828.tar.gz"
)
!
let
result
=
Task
{
()
->
[
TarEntry
]?
in
debugPrint
(
"Downloading 20 Newsgroups dataset..."
)
let
data
=
try
await
downloadData
(
from
:
url
)
//TODO: Decompression seems to be taking a lot of time right now? Different library?
debugPrint
(
"Decompressing 20 Newsgroups dataset..."
)
let
decompressedData
=
try
?
GzipArchive
.
unarchive
(
archive
:
data
)
if
let
decompressedData
=
decompressedData
{
let
tarData
=
try
?
TarContainer
.
open
(
container
:
decompressedData
)
return
tarData
}
debugPrint
(
"Unable to open TAR."
)
return
nil
}
let
tarData
=
try
?
await
result
.
value
var
newsgroupData
:
[
String
]
=
[
String
]()
newsgroupData
.
reserveCapacity
(
tarData
!.
count
)
for
entry
in
tarData
!
{
if
let
data
=
entry
.
data
{
if
let
string
=
String
(
data
:
data
,
encoding
:
.
ascii
)
{
newsgroupData
.
append
(
string
)
}
else
{
debugPrint
(
"
\(
entry
.
info
.
name
)
could not be converted to ASCII string."
)
}
}
}
return
newsgroupData
}
// 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 SWCompression
//
//@inlinable
//func downloadData(from url: URL) async throws -> Data {
// let (data, _) = try await URLSession.shared.data(from: url)
// return data
//}
//
//
//func download20Newsgroups() async -> [String] {
// let url = URL(string: "http://qwone.com/~jason/20Newsgroups/20news-18828.tar.gz")!
//
// let result = Task { () -> [TarEntry]? in
//
// debugPrint("Downloading 20 Newsgroups dataset...")
// let data = try await downloadData(from: url)
//
// //TODO: Decompression seems to be taking a lot of time right now? Different library?
// debugPrint("Decompressing 20 Newsgroups dataset...")
// let decompressedData = try? GzipArchive.unarchive(archive: data)
// if let decompressedData = decompressedData {
// let tarData = try? TarContainer.open(container: decompressedData)
// return tarData
// }
// debugPrint("Unable to open TAR.")
// return nil
// }
//
// let tarData = try? await result.value
//
// var newsgroupData: [String] = [String]()
// newsgroupData.reserveCapacity(tarData!.count)
//
// for entry in tarData! {
// if let data = entry.data {
// if let string = String(data: data, encoding: .ascii) {
// newsgroupData.append(string)
// } else {
// debugPrint("\(entry.info.name) could not be converted to ASCII string.")
// }
// }
// }
//
// return newsgroupData
//}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment