Initial Qrious v0.1

This commit is contained in:
Navan Chauhan 2020-07-24 11:19:43 +05:30
commit 056eec2d13
29 changed files with 33548 additions and 0 deletions

View File

@ -0,0 +1,408 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
3EE5A59B24C80E3900A947E2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A59A24C80E3900A947E2 /* AppDelegate.swift */; };
3EE5A59D24C80E3900A947E2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A59C24C80E3900A947E2 /* SceneDelegate.swift */; };
3EE5A5A024C80E3900A947E2 /* Qrious.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A59E24C80E3900A947E2 /* Qrious.xcdatamodeld */; };
3EE5A5A224C80E3900A947E2 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5A124C80E3900A947E2 /* ContentView.swift */; };
3EE5A5A424C80E3F00A947E2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3EE5A5A324C80E3F00A947E2 /* Assets.xcassets */; };
3EE5A5A724C80E3F00A947E2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3EE5A5A624C80E3F00A947E2 /* Preview Assets.xcassets */; };
3EE5A5AA24C80E3F00A947E2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3EE5A5A824C80E3F00A947E2 /* LaunchScreen.storyboard */; };
3EE5A5B324C82A0800A947E2 /* DetailedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5B224C82A0800A947E2 /* DetailedView.swift */; };
3EE5A5B524C85CF100A947E2 /* SwiftyJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5B424C85CF100A947E2 /* SwiftyJSON.swift */; };
3EE5A5B724C866B300A947E2 /* BERTQAFP16.mlmodel in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5B624C866B200A947E2 /* BERTQAFP16.mlmodel */; };
3EE5A5BE24C86CE400A947E2 /* bert-base-uncased-vocab.txt in Resources */ = {isa = PBXBuildFile; fileRef = 3EE5A5B824C86CE400A947E2 /* bert-base-uncased-vocab.txt */; };
3EE5A5BF24C86CE400A947E2 /* BERT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5B924C86CE400A947E2 /* BERT.swift */; };
3EE5A5C024C86CE400A947E2 /* BERTInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5BA24C86CE400A947E2 /* BERTInput.swift */; };
3EE5A5C124C86CE400A947E2 /* BERTOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5BB24C86CE400A947E2 /* BERTOutput.swift */; };
3EE5A5C224C86CE400A947E2 /* BERTVocabulary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5BC24C86CE400A947E2 /* BERTVocabulary.swift */; };
3EE5A5C324C86CE400A947E2 /* TokenizedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE5A5BD24C86CE400A947E2 /* TokenizedString.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
3EE5A59724C80E3900A947E2 /* Qrious.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Qrious.app; sourceTree = BUILT_PRODUCTS_DIR; };
3EE5A59A24C80E3900A947E2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3EE5A59C24C80E3900A947E2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
3EE5A59F24C80E3900A947E2 /* Qrious.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Qrious.xcdatamodel; sourceTree = "<group>"; };
3EE5A5A124C80E3900A947E2 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
3EE5A5A324C80E3F00A947E2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3EE5A5A624C80E3F00A947E2 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
3EE5A5A924C80E3F00A947E2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
3EE5A5AB24C80E3F00A947E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3EE5A5B124C8122B00A947E2 /* Qrious.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Qrious.entitlements; sourceTree = "<group>"; };
3EE5A5B224C82A0800A947E2 /* DetailedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailedView.swift; sourceTree = "<group>"; };
3EE5A5B424C85CF100A947E2 /* SwiftyJSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyJSON.swift; sourceTree = "<group>"; };
3EE5A5B624C866B200A947E2 /* BERTQAFP16.mlmodel */ = {isa = PBXFileReference; lastKnownFileType = file.mlmodel; path = BERTQAFP16.mlmodel; sourceTree = "<group>"; };
3EE5A5B824C86CE400A947E2 /* bert-base-uncased-vocab.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "bert-base-uncased-vocab.txt"; sourceTree = "<group>"; };
3EE5A5B924C86CE400A947E2 /* BERT.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BERT.swift; sourceTree = "<group>"; };
3EE5A5BA24C86CE400A947E2 /* BERTInput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BERTInput.swift; sourceTree = "<group>"; };
3EE5A5BB24C86CE400A947E2 /* BERTOutput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BERTOutput.swift; sourceTree = "<group>"; };
3EE5A5BC24C86CE400A947E2 /* BERTVocabulary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BERTVocabulary.swift; sourceTree = "<group>"; };
3EE5A5BD24C86CE400A947E2 /* TokenizedString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenizedString.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
3EE5A59424C80E3900A947E2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
3EE5A58E24C80E3900A947E2 = {
isa = PBXGroup;
children = (
3EE5A59924C80E3900A947E2 /* Qrious */,
3EE5A59824C80E3900A947E2 /* Products */,
);
sourceTree = "<group>";
};
3EE5A59824C80E3900A947E2 /* Products */ = {
isa = PBXGroup;
children = (
3EE5A59724C80E3900A947E2 /* Qrious.app */,
);
name = Products;
sourceTree = "<group>";
};
3EE5A59924C80E3900A947E2 /* Qrious */ = {
isa = PBXGroup;
children = (
3EE5A5B624C866B200A947E2 /* BERTQAFP16.mlmodel */,
3EE5A5B424C85CF100A947E2 /* SwiftyJSON.swift */,
3EE5A5B124C8122B00A947E2 /* Qrious.entitlements */,
3EE5A59A24C80E3900A947E2 /* AppDelegate.swift */,
3EE5A59C24C80E3900A947E2 /* SceneDelegate.swift */,
3EE5A5A124C80E3900A947E2 /* ContentView.swift */,
3EE5A5B224C82A0800A947E2 /* DetailedView.swift */,
3EE5A5B824C86CE400A947E2 /* bert-base-uncased-vocab.txt */,
3EE5A5B924C86CE400A947E2 /* BERT.swift */,
3EE5A5BA24C86CE400A947E2 /* BERTInput.swift */,
3EE5A5BB24C86CE400A947E2 /* BERTOutput.swift */,
3EE5A5BC24C86CE400A947E2 /* BERTVocabulary.swift */,
3EE5A5BD24C86CE400A947E2 /* TokenizedString.swift */,
3EE5A5A324C80E3F00A947E2 /* Assets.xcassets */,
3EE5A5A824C80E3F00A947E2 /* LaunchScreen.storyboard */,
3EE5A5AB24C80E3F00A947E2 /* Info.plist */,
3EE5A59E24C80E3900A947E2 /* Qrious.xcdatamodeld */,
3EE5A5A524C80E3F00A947E2 /* Preview Content */,
);
path = Qrious;
sourceTree = "<group>";
};
3EE5A5A524C80E3F00A947E2 /* Preview Content */ = {
isa = PBXGroup;
children = (
3EE5A5A624C80E3F00A947E2 /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
3EE5A59624C80E3900A947E2 /* Qrious */ = {
isa = PBXNativeTarget;
buildConfigurationList = 3EE5A5AE24C80E3F00A947E2 /* Build configuration list for PBXNativeTarget "Qrious" */;
buildPhases = (
3EE5A59324C80E3900A947E2 /* Sources */,
3EE5A59424C80E3900A947E2 /* Frameworks */,
3EE5A59524C80E3900A947E2 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Qrious;
productName = Qrious;
productReference = 3EE5A59724C80E3900A947E2 /* Qrious.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
3EE5A58F24C80E3900A947E2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1160;
LastUpgradeCheck = 1160;
ORGANIZATIONNAME = "Navan Chauhan";
TargetAttributes = {
3EE5A59624C80E3900A947E2 = {
CreatedOnToolsVersion = 11.6;
};
};
};
buildConfigurationList = 3EE5A59224C80E3900A947E2 /* Build configuration list for PBXProject "Qrious" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 3EE5A58E24C80E3900A947E2;
productRefGroup = 3EE5A59824C80E3900A947E2 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
3EE5A59624C80E3900A947E2 /* Qrious */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
3EE5A59524C80E3900A947E2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3EE5A5AA24C80E3F00A947E2 /* LaunchScreen.storyboard in Resources */,
3EE5A5A724C80E3F00A947E2 /* Preview Assets.xcassets in Resources */,
3EE5A5BE24C86CE400A947E2 /* bert-base-uncased-vocab.txt in Resources */,
3EE5A5A424C80E3F00A947E2 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
3EE5A59324C80E3900A947E2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3EE5A5B724C866B300A947E2 /* BERTQAFP16.mlmodel in Sources */,
3EE5A59B24C80E3900A947E2 /* AppDelegate.swift in Sources */,
3EE5A5BF24C86CE400A947E2 /* BERT.swift in Sources */,
3EE5A5A024C80E3900A947E2 /* Qrious.xcdatamodeld in Sources */,
3EE5A5C324C86CE400A947E2 /* TokenizedString.swift in Sources */,
3EE5A5C024C86CE400A947E2 /* BERTInput.swift in Sources */,
3EE5A5C224C86CE400A947E2 /* BERTVocabulary.swift in Sources */,
3EE5A5B324C82A0800A947E2 /* DetailedView.swift in Sources */,
3EE5A5B524C85CF100A947E2 /* SwiftyJSON.swift in Sources */,
3EE5A5C124C86CE400A947E2 /* BERTOutput.swift in Sources */,
3EE5A5A224C80E3900A947E2 /* ContentView.swift in Sources */,
3EE5A59D24C80E3900A947E2 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
3EE5A5A824C80E3F00A947E2 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
3EE5A5A924C80E3F00A947E2 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
3EE5A5AC24C80E3F00A947E2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
3EE5A5AD24C80E3F00A947E2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.6;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
3EE5A5AF24C80E3F00A947E2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Qrious/Qrious.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Qrious/Preview Content\"";
DEVELOPMENT_TEAM = 6BS49F3GLW;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Qrious/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.5;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.navanchauhan.Qrious;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
3EE5A5B024C80E3F00A947E2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Qrious/Qrious.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Qrious/Preview Content\"";
DEVELOPMENT_TEAM = 6BS49F3GLW;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Qrious/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.5;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.navanchauhan.Qrious;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
3EE5A59224C80E3900A947E2 /* Build configuration list for PBXProject "Qrious" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3EE5A5AC24C80E3F00A947E2 /* Debug */,
3EE5A5AD24C80E3F00A947E2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
3EE5A5AE24C80E3F00A947E2 /* Build configuration list for PBXNativeTarget "Qrious" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3EE5A5AF24C80E3F00A947E2 /* Debug */,
3EE5A5B024C80E3F00A947E2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
3EE5A59E24C80E3900A947E2 /* Qrious.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
3EE5A59F24C80E3900A947E2 /* Qrious.xcdatamodel */,
);
currentVersion = 3EE5A59F24C80E3900A947E2 /* Qrious.xcdatamodel */;
path = Qrious.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 3EE5A58F24C80E3900A947E2 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Qrious.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

1
Qrious/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.mlmodel filter=lfs diff=lfs merge=lfs -text

82
Qrious/AppDelegate.swift Normal file
View File

@ -0,0 +1,82 @@
//
// AppDelegate.swift
// Qrious
//
// Created by Navan Chauhan on 22/07/20.
// Copyright © 2020 Navan Chauhan. All rights reserved.
//
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "Qrious")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
// MARK: - Core Data Saving support
func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
}

View File

@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "first.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "second.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

61
Qrious/BERT.swift Normal file
View File

@ -0,0 +1,61 @@
/*
See LICENSE folder for this samples licensing information.
Abstract:
Wrapper class for the BERT model that handles its input and output.
*/
import CoreML
class BERT {
/// The underlying Core ML Model.
var bertModel: BERTQAFP16 {
do {
return try BERTQAFP16(configuration: .init())
} catch {
fatalError("Couldn't load BERT model due to: \(error.localizedDescription)")
}
}
/// Finds an answer to a given question by searching a document's text.
///
/// - parameters:
/// - question: The user's question about a document.
/// - document: The document text that (should) contain an answer.
/// - returns: The answer string or an error descripton.
/// - Tag: FindAnswerForQuestionInDocument
func findAnswer(for question: String, in document: String) -> Substring {
// Prepare the input for the BERT model.
let bertInput = BERTInput(documentString: document, questionString: question)
guard bertInput.totalTokenSize <= BERTInput.maxTokens else {
var message = "Text and question are too long"
message += " (\(bertInput.totalTokenSize) tokens)"
message += " for the BERT model's \(BERTInput.maxTokens) token limit."
return Substring(message)
}
// The MLFeatureProvider that supplies the BERT model with its input MLMultiArrays.
let modelInput = bertInput.modelInput!
// Make a prediction with the BERT model.
guard let prediction = try? bertModel.prediction(input: modelInput) else {
return "The BERT model is unable to make a prediction."
}
// Analyze the output form the BERT model.
guard let bestLogitIndices = bestLogitsIndices(from: prediction,
in: bertInput.documentRange) else {
return "Couldn't find a valid answer. Please try again."
}
// Find the indices of the original string.
let documentTokens = bertInput.document.tokens
let answerStart = documentTokens[bestLogitIndices.start].startIndex
let answerEnd = documentTokens[bestLogitIndices.end].endIndex
// Return the portion of the original string as the answer.
let originalText = bertInput.document.original
return originalText[answerStart..<answerEnd]
}
}

101
Qrious/BERTInput.swift Normal file
View File

@ -0,0 +1,101 @@
/*
See LICENSE folder for this samples licensing information.
Abstract:
Provides helper types for the BERT model's inputs.
*/
import CoreML
struct BERTInput {
/// The maximum number of tokens the BERT model can process.
static let maxTokens = 384
// There are 2 sentinel tokens before the document, 1 [CLS] token and 1 [SEP] token.
static private let documentTokenOverhead = 2
// There are 3 sentinel tokens total, 1 [CLS] token and 2 [SEP] tokens.
static private let totalTokenOverhead = 3
var modelInput: BERTQAFP16Input?
let question: TokenizedString
let document: TokenizedString
private let documentOffset: Int
var documentRange: Range<Int> {
return documentOffset..<documentOffset + document.tokens.count
}
var totalTokenSize: Int {
return BERTInput.totalTokenOverhead + document.tokens.count + question.tokens.count
}
/// - Tag: BERTInputInitializer
init(documentString: String, questionString: String) {
document = TokenizedString(documentString)
question = TokenizedString(questionString)
// Save the number of tokens before the document tokens for later.
documentOffset = BERTInput.documentTokenOverhead + question.tokens.count
guard totalTokenSize < BERTInput.maxTokens else {
return
}
// Start the wordID array with the `classification start` token.
var wordIDs = [BERTVocabulary.classifyStartTokenID]
// Add the question tokens and a separator.
wordIDs += question.tokenIDs
wordIDs += [BERTVocabulary.separatorTokenID]
// Add the document tokens and a separator.
wordIDs += document.tokenIDs
wordIDs += [BERTVocabulary.separatorTokenID]
// Fill the remaining token slots with padding tokens.
let tokenIDPadding = BERTInput.maxTokens - wordIDs.count
wordIDs += Array(repeating: BERTVocabulary.paddingTokenID, count: tokenIDPadding)
guard wordIDs.count == BERTInput.maxTokens else {
fatalError("`wordIDs` array size isn't the right size.")
}
// Build the token types array in the same order.
// The document tokens are type 1 and all others are type 0.
// Set all of the token types before the document to 0.
var wordTypes = Array(repeating: 0, count: documentOffset)
// Set all of the document token types to 1.
wordTypes += Array(repeating: 1, count: document.tokens.count)
// Set the remaining token types to 0.
let tokenTypePadding = BERTInput.maxTokens - wordTypes.count
wordTypes += Array(repeating: 0, count: tokenTypePadding)
guard wordTypes.count == BERTInput.maxTokens else {
fatalError("`wordTypes` array size isn't the right size.")
}
// Create the MLMultiArray instances.
let tokenIDMultiArray = try? MLMultiArray(wordIDs)
let wordTypesMultiArray = try? MLMultiArray(wordTypes)
// Unwrap the MLMultiArray optionals.
guard let tokenIDInput = tokenIDMultiArray else {
fatalError("Couldn't create wordID MLMultiArray input")
}
guard let tokenTypeInput = wordTypesMultiArray else {
fatalError("Couldn't create wordType MLMultiArray input")
}
// Create the BERT input MLFeatureProvider.
let modelInput = BERTQAFP16Input(wordIDs: tokenIDInput,
wordTypes: tokenTypeInput)
self.modelInput = modelInput
}
}

102
Qrious/BERTOutput.swift Normal file
View File

@ -0,0 +1,102 @@
/*
See LICENSE folder for this samples licensing information.
Abstract:
Provides helper types for the BERT model's outputs.
*/
import CoreML
extension Array where Element: Comparable {
/// Provides the indices of the largest elements.
///
/// - parameters:
/// - count: The number of indicies to return, at most.
/// - returns: An array of integers.
func indicesOfLargest(_ count: Int = 10) -> [Int] {
let count = Swift.min(count, self.count)
let sortedSelf = enumerated().sorted { (arg0, arg1) in arg0.element > arg1.element }
let topElements = sortedSelf[0..<count]
let topIndices = topElements.map { (tuple) in tuple.offset }
return topIndices
}
}
extension MLMultiArray {
/// Creates a copy of the multi-array's contents into a Doubles array.
///
/// - returns: An array of Doubles.
func doubleArray() -> [Double] {
// Bind the underlying `dataPointer` memory to make a native swift `Array<Double>`
let unsafeMutablePointer = dataPointer.bindMemory(to: Double.self, capacity: count)
let unsafeBufferPointer = UnsafeBufferPointer(start: unsafeMutablePointer, count: count)
return [Double](unsafeBufferPointer)
}
}
extension BERT {
/// Finds the indices of the best start logit and end logit given a prediction output and a range.
///
/// - parameters:
/// - prediction: A feature provider that supplies the output MLMultiArrays from a BERT model.
/// - range: A range of the output tokens to search.
/// - returns: Description.
/// - Tag: BestLogitIndices
func bestLogitsIndices(from prediction: BERTQAFP16Output, in range: Range<Int>) -> (start: Int, end: Int)? {
// Convert the logits MLMultiArrays to [Double].
let startLogits = prediction.startLogits.doubleArray()
let endLogits = prediction.endLogits.doubleArray()
// Isolate the logits for the document.
let startLogitsOfDoc = [Double](startLogits[range])
let endLogitsOfDoc = [Double](endLogits[range])
// Only keep the top 20 (out of the possible ~380) indices for faster searching.
let topStartIndices = startLogitsOfDoc.indicesOfLargest(20)
let topEndIndices = endLogitsOfDoc.indicesOfLargest(20)
// Search for the highest valued logit pairing.
let bestPair = findBestLogitPair(startLogits: startLogitsOfDoc,
bestStartIndices: topStartIndices,
endLogits: endLogitsOfDoc,
bestEndIndices: topEndIndices)
guard bestPair.start >= 0 && bestPair.end >= 0 else {
return nil
}
return bestPair
}
/// Searches the given indices for the highest valued start and end logits.
///
/// - parameters:
/// - startLogits: An array of all the start logits.
/// - bestStartIndices: An array of the best start logit indices.
/// - endLogits: An array of all the end logits.
/// - bestEndIndices: An array of the best end logit indices.
/// - returns: A tuple of the best start index and best end index.
func findBestLogitPair(startLogits: [Double],
bestStartIndices: [Int],
endLogits: [Double],
bestEndIndices: [Int]) -> (start: Int, end: Int) {
let logitsCount = startLogits.count
var bestSum = -Double.infinity
var bestStart = -1
var bestEnd = -1
for start in 0..<logitsCount where bestStartIndices.contains(start) {
for end in start..<logitsCount where bestEndIndices.contains(end) {
let logitSum = startLogits[start] + endLogits[end]
if logitSum > bestSum {
bestSum = logitSum
bestStart = start
bestEnd = end
}
}
}
return (bestStart, bestEnd)
}
}

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e748f5c7de392b2e2c1502689bb61984145e685549573edda811ebc2aee59da1
size 217828595

View File

@ -0,0 +1,70 @@
/*
See LICENSE folder for this samples licensing information.
Abstract:
Abstracts the BERT vocabulary setup to two tokenID methods and four constants.
*/
import Foundation
struct BERTVocabulary {
static let unkownTokenID = lookupDictionary["[UNK]"]! // 100
static let paddingTokenID = lookupDictionary["[PAD]"]! // 0
static let separatorTokenID = lookupDictionary["[SEP]"]! // 102
static let classifyStartTokenID = lookupDictionary["[CLS]"]! // 101
/// Searches for a token ID for the given word or wordpiece string.
///
/// - parameters:
/// - string: A word or wordpiece string.
/// - returns: A token ID.
static func tokenID(of string: String) -> Int {
let token = Substring(string)
return tokenID(of: token)
}
/// Searches for a token ID for the given word or wordpiece token.
///
/// - parameters:
/// - string: A word or wordpiece token (Substring).
/// - returns: A token ID.
static func tokenID(of token: Substring) -> Int {
let unkownTokenID = BERTVocabulary.unkownTokenID
return BERTVocabulary.lookupDictionary[token] ?? unkownTokenID
}
private init() { }
private static let lookupDictionary = loadVocabulary()
/// Imports the model's vocabulary into a [word/wordpiece token: token ID] Dictionary.
///
/// - returns: A dictionary.
/// - Tag: LoadVocabulary
private static func loadVocabulary() -> [Substring: Int] {
let fileName = "bert-base-uncased-vocab"
let expectedVocabularySize = 30_522
guard let url = Bundle.main.url(forResource: fileName, withExtension: "txt") else {
fatalError("Vocabulary file is missing")
}
guard let rawVocabulary = try? String(contentsOf: url) else {
fatalError("Vocabulary file has no contents.")
}
let words = rawVocabulary.split(separator: "\n")
guard words.count == expectedVocabularySize else {
fatalError("Vocabulary file is not the correct size.")
}
guard words.first! == "[PAD]" && words.last! == "##" else {
fatalError("Vocabulary file contents appear to be incorrect.")
}
let values = 0..<words.count
let vocabulary = Dictionary(uniqueKeysWithValues: zip(words, values))
return vocabulary
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

193
Qrious/ContentView.swift Normal file
View File

@ -0,0 +1,193 @@
//
// ContentView.swift
// Qrious
//
// Created by Navan Chauhan on 22/07/20.
// Copyright © 2020 Navan Chauhan. All rights reserved.
//
import SwiftUI
struct Todo: Codable, Identifiable {
public var id: Int
public var title: String
public var published_date: String
public var defined_type_name: String
public var url: String
public var description1: String?
public var paperURL: String?
public var candidates: String?
}
// group=13668 ( Chemrxiv )
class FetchToDo: ObservableObject {
@Published var query: String = ""
@Published var todos = [Todo]()
init() {
//var request = URLRequest(url: URL(string: "https://api.figshare.com/v2/articles/search?search_for=\(q)&page_size=\(p)")!)
var request = URLRequest(url: URL(string: "https://api.figshare.com/v2/articles/search?page_size=20")!)
request.httpMethod = "POST"
//let url = URL(string: "https://jsonplaceholder.typicode.com/todos")!
URLSession.shared.dataTask(with: request) {(data, response, error) in
do {
if let todoData = data {
let decodedData = try JSONDecoder().decode([Todo].self, from: todoData)
DispatchQueue.main.async {
self.todos = decodedData
}
} else {
print("No data")
}
} catch {
print("Error")
}
}.resume()
}
func fetchAgain(q: String = "Hepatitis+B+Virus+Silico",p: String = "10",limit: Bool = false) {
var s = "https://api.figshare.com/v2/articles/search?search_for=\(q.replacingOccurrences(of: " ", with: "+"))&page_size=\(p)"
//var request = URLRequest(url: URL(string: "https://api.figshare.com/v2/articles/search?search_for=\(q)&page_size=\(p)")!)
if limit {
s += "&group=13668"
}
print(s, limit)
var request = URLRequest(url: URL(string: s)!)
request.httpMethod = "POST"
//let url = URL(string: "https://jsonplaceholder.typicode.com/todos")!
URLSession.shared.dataTask(with: request) {(data, response, error) in
do {
if let todoData = data {
let decodedData = try JSONDecoder().decode([Todo].self, from: todoData)
DispatchQueue.main.async {
self.todos = decodedData
}
} else {
print("No data")
}
} catch {
print("Error")
}
}.resume()
}
}
extension UIApplication {
func endEditing() {
sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
class configuration: ObservableObject {
@Published var question: String = "Results show what are the compounds?"
}
struct ContentView: View {
@State private var selection = 0
@State private var advance = true
@State public var query = "Covid-19 Compounds"
@State public var noOfArticles = "15"
@State private var executed = false
@EnvironmentObject var config: configuration
@State private var ques: String = configuration().question
//"Results show what top compounds?"
@State public var LimitToChemrxiv: Bool = false
@ObservedObject var fetch = FetchToDo()
//let bert = BERTQAFP16()
var body: some View {
TabView(selection: $selection){
NavigationView{
VStack{
/*
HStack{
Text("Configuration")
.font(.title)
.fontWeight(.semibold)
.multilineTextAlignment(.leading)
}*/
Form{
Section(header: Text("Search Query")){
TextField("Search Query",text: $query)
}
Section(header: Text("Configuration")){
VStack{
HStack{
Text("No. Of Articles:")
TextField("No. Of Articles", text: $noOfArticles)
.keyboardType(.numberPad)
}.disabled(!advance)
HStack{
Toggle(isOn: $LimitToChemrxiv){
Text("Limit to ChemRxiv")
}
}
}
}
Section(header: Text("Query for AI Model")){
TextField("",text: $ques, onEditingChanged: {_ in self.config.question = self.ques})
}
Section{
Button(action: {self.fetch.fetchAgain(q: self.query, p: String(self.noOfArticles), limit: self.LimitToChemrxiv)}){
Text("Get Papers")
}
}
}
Text("OwO")
.frame(height: 50.0)
}
.navigationBarTitle(Text("Qrious"))
}
.tabItem {
VStack {
Image(systemName: "gear")
.font(.title) //Image("first")
Text("Configuration")
}
}
.tag(0)
NavigationView{
//Text(" View").font(.title)
VStack {
List(fetch.todos) { todo in NavigationLink(destination: DetailedView(article: todo)){
VStack(alignment: .leading) {
Text(todo.title)
Text("\(todo.published_date)")
.font(.system(size: 11))
.foregroundColor(Color.gray)
}}
}
}
.navigationBarTitle("Articles")
}
.tabItem {
VStack {
Image(systemName: "list.bullet")
.font(.title)
Text("Articles")
}
}
.tag(1)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}

127
Qrious/DetailedView.swift Normal file
View File

@ -0,0 +1,127 @@
//
// DetailedView.swift
// Qrious
//
// Created by Navan Chauhan on 22/07/20.
// Copyright © 2020 Navan Chauhan. All rights reserved.
//
import SwiftUI
extension String {
public var withoutHtml: String {
guard let data = self.data(using: .utf8) else {
return self
}
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf8.rawValue
]
guard let attributedString = try? NSAttributedString(data: data, options: options, documentAttributes: nil) else {
return self
}
return attributedString.string
}
}
struct DetailedView: View {
//public var description: String
//@State public var defined_type_name: String = "p"
@EnvironmentObject var config: configuration
@State private var description1: String = "Loading.."
@State private var paperURL: String = "Fetching..."
@State private var candidates: String = "Extracting Compounds"
func fetch(articleURL: String) {
//let url = URL(string: "\(articleURL)")!
var request = URLRequest(url: URL(string: articleURL)!)
request.httpMethod = "GET"
print(request)
// 2.
URLSession.shared.dataTask(with: request) {(data, response, error) in
do {
if let todoData = data {
// 3.
//let decodedData = try JSONDecoder().decode([Paper].self, from: todoData)
let decodedData = try JSON(data: todoData)
DispatchQueue.main.async {
self.description1 = decodedData["description"].string!
self.paperURL = decodedData["figshare_url"].string!
print("Finding Answer")
self.candidates = String(BERT().findAnswer(for: configuration().question, in: self.description1))
//return decodedData
}
} else {
print("No data")
}
} catch {
print("Error")
}
}.resume()
}
let article: Todo
var body: some View {
NavigationView{
VStack{
Text(article.title)
.font(.title)
.fontWeight(.bold)
.contextMenu {
Button(action: {
UIPasteboard.general.string = self.article.title
}) {
Text("Copy")
Image(systemName: "copy")
}}
Button("Paper URL") {
UIApplication.shared.open(URL(string: self.paperURL)!)
}
Text("Possible Candidates")
.font(.headline)
.fontWeight(.semibold)
.multilineTextAlignment(.leading)
Text(self.candidates)
Text("Abstract")
.font(.headline)
.fontWeight(.semibold)
ScrollView(.vertical){
VStack{
Text(description1)
//Text(description1.withoutHtml)
}
.frame(maxWidth: .infinity)
}
}
.navigationBarTitle(Text(String(self.article.defined_type_name))
.font(.largeTitle)
.fontWeight(.black), displayMode: .inline)
}.onAppear {
self.fetch(articleURL: self.article.url)
}
}
}
#if DEBUG
struct DetailedView_Previews: PreviewProvider {
static var previews: some View {
DetailedView(
article: Todo(
id: 0,
title: "Sample Paper Name",
published_date: "Excatly",
defined_type_name: "Lmao",
url: "https://google.com"
)
)
}
}
#endif

70
Qrious/Info.plist Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarTintParameters</key>
<dict>
<key>UINavigationBar</key>
<dict>
<key>Style</key>
<string>UIBarStyleDefault</string>
<key>Translucent</key>
<false/>
</dict>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Qrious.xcdatamodel</string>
</dict>
</plist>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
<elements/>
</model>

View File

@ -0,0 +1,71 @@
//
// SceneDelegate.swift
// Qrious
//
// Created by Navan Chauhan on 22/07/20.
// Copyright © 2020 Navan Chauhan. All rights reserved.
//
import UIKit
import SwiftUI
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Get the managed object context from the shared persistent container.
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
// Create the SwiftUI view and set the context as the value for the managedObjectContext environment keyPath.
// Add `@Environment(\.managedObjectContext)` in the views that will need the context.
let contentView = ContentView().environment(\.managedObjectContext, context)
// Use a UIHostingController as window root view controller.
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
let config = configuration()
window.rootViewController = UIHostingController(rootView: contentView.environmentObject(config))
self.window = window
window.makeKeyAndVisible()
}
}
func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
// Save changes in the application's managed object context when the application transitions to the background.
(UIApplication.shared.delegate as? AppDelegate)?.saveContext()
}
}

1401
Qrious/SwiftyJSON.swift Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
/*
See LICENSE folder for this samples licensing information.
Abstract:
Helper type for BERTInput.swift that converts a string into tokens and their IDs.
*/
import NaturalLanguage
struct TokenizedString {
private let _tokens: [Substring]
private let _tokenIDs: [Int]
let original: String
public var tokens: [Substring] { return _tokens }
public var tokenIDs: [Int] { return _tokenIDs }
init(_ string: String) {
original = string
let result = TokenizedString.tokenize(string)
_tokens = result.tokens
_tokenIDs = result.tokenIDs
}
/// Fragments the given text into an array of tokens and their IDs.
///
/// - parameters:
/// - string: A body of text.
/// - returns: A tuple of an two arrays: one for tokens and another for their IDs.
private static func tokenize(_ string: String) -> (tokens: [Substring], tokenIDs: [Int]) {
let tokens = wordTokens(from: string)
return wordpieceTokens(from: tokens)
}
/// Splits the given raw text into an array of word tokens.
///
/// - parameters:
/// - rawString: A body of text.
/// - returns: An array of substrings.
/// - Tag: WordTokensFromRawString
private static func wordTokens(from rawString: String) -> [Substring] {
// Store the tokenized substrings into an array.
var wordTokens = [Substring]()
// Use Natural Language's NLTagger to tokenize the input by word.
let tagger = NLTagger(tagSchemes: [.tokenType])
tagger.string = rawString
// Find all tokens in the string and append to the array.
tagger.enumerateTags(in: rawString.startIndex..<rawString.endIndex,
unit: .word,
scheme: .tokenType,
options: [.omitWhitespace]) { (_, range) -> Bool in
wordTokens.append(rawString[range])
return true
}
return wordTokens
}
/// Splits each word token into its component wordpiece tokens, if possible.
///
/// - parameters:
/// - wordTokens: An array of word tokens.
/// - returns: A tuple of an two arrays: one for word/wordpiece tokens and another for their IDs.
/// - Tag: WordpieceTokens
private static func wordpieceTokens(from wordTokens: [Substring]) -> (tokens: [Substring], tokenIDs: [Int]) {
var wordpieceTokens = [Substring]()
var wordpieceTokenIDs = [Int]()
// Interate through each word and see if can be broken up into pieces.
for token in wordTokens {
// Skip tokens that are too long.
guard token.count <= 100 else {
wordpieceTokens.append(token)
wordpieceTokenIDs.append(BERTVocabulary.unkownTokenID)
continue
}
var subTokens = [Substring]()
var subTokenIDs = [Int]()
// Start with the whole token.
var subToken = token
// Note when we've found the root word.
var foundFirstSubtoken = false
while !subToken.isEmpty {
// Word suffixes begin with ## in the vocabulary, such as `##ing`.
let prefix = foundFirstSubtoken ? "##" : ""
// Convert the string to lowercase to match the vocabulary.
let searchTerm = Substring(prefix + subToken).lowercased()
let subTokenID = BERTVocabulary.tokenID(of: searchTerm)
if subTokenID == BERTVocabulary.unkownTokenID {
// Remove the last character and try again.
let nextSubtoken = subToken.dropLast()
if nextSubtoken.isEmpty {
// This token and its components are not in the vocabulary.
subTokens = [token]
subTokenIDs = [BERTVocabulary.unkownTokenID]
// Exit the while-loop, but continue the for-loop.
break
}
// Prepare for the next iteration of the while-loop.
subToken = nextSubtoken
} else {
// Note that this loop has found the first subtoken.
// Ok to set true for additional subtokens.
foundFirstSubtoken = true
// Save this wordpiece and its ID.
subTokens.append(subToken)
subTokenIDs.append(subTokenID)
// Repeat search with the token's remainder, if any.
subToken = token.suffix(from: subToken.endIndex)
}
} // End of while-loop
// Append all of this token's sub-tokens and their IDs.
wordpieceTokens += subTokens
wordpieceTokenIDs += subTokenIDs
} // End of for-loop
guard wordpieceTokens.count == wordpieceTokenIDs.count else {
fatalError("Tokens array and TokenIDs arrays must be the same size.")
}
return (wordpieceTokens, wordpieceTokenIDs)
}
}

File diff suppressed because it is too large Load Diff

1
README.md Normal file
View File

@ -0,0 +1 @@
# Qrious