All Projects → soulverteam → Soulvercore

soulverteam / Soulvercore

A powerful Swift framework for evaluating mathematical expressions

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Soulvercore

Ludwig
Data-centric declarative deep learning framework
Stars: ✭ 8,018 (+3172.65%)
Mutual labels:  natural-language-processing, natural-language
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (-62.45%)
Mutual labels:  datetime, timezone
When
A natural language date/time parser with pluggable rules
Stars: ✭ 1,113 (+354.29%)
Mutual labels:  datetime, natural-language
Nlp Recipes
Natural Language Processing Best Practices & Examples
Stars: ✭ 5,783 (+2260.41%)
Mutual labels:  natural-language-processing, natural-language
Anydate
Swifty Date & Time API inspired from Java 8 DateTime API.
Stars: ✭ 178 (-27.35%)
Mutual labels:  datetime, timezone
Wikisql
A large annotated semantic parsing corpus for developing natural language interfaces.
Stars: ✭ 965 (+293.88%)
Mutual labels:  natural-language-processing, natural-language
Forte
Forte is a flexible and powerful NLP builder FOR TExt. This is part of the CASL project: http://casl-project.ai/
Stars: ✭ 89 (-63.67%)
Mutual labels:  natural-language-processing, natural-language
Botlibre
An open platform for artificial intelligence, chat bots, virtual agents, social media automation, and live chat automation.
Stars: ✭ 412 (+68.16%)
Mutual labels:  natural-language-processing, natural-language
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+709.39%)
Mutual labels:  datetime, timezone
Delorean
Delorean: Time Travel Made Easy
Stars: ✭ 1,793 (+631.84%)
Mutual labels:  datetime, timezone
Mycroft Core
Mycroft Core, the Mycroft Artificial Intelligence platform.
Stars: ✭ 5,489 (+2140.41%)
Mutual labels:  natural-language-processing, natural-language
Date
A date and time library based on the C++11/14/17 <chrono> header
Stars: ✭ 2,389 (+875.1%)
Mutual labels:  datetime, timezone
Languagetool
Style and Grammar Checker for 25+ Languages
Stars: ✭ 5,641 (+2202.45%)
Mutual labels:  natural-language-processing, natural-language
Coursera Natural Language Processing Specialization
Programming assignments from all courses in the Coursera Natural Language Processing Specialization offered by deeplearning.ai.
Stars: ✭ 39 (-84.08%)
Mutual labels:  natural-language-processing, natural-language
Dateutils
nifty command line date and time utilities; fast date calculations and conversion in the shell
Stars: ✭ 458 (+86.94%)
Mutual labels:  datetime, timezone
Text Analytics With Python
Learn how to process, classify, cluster, summarize, understand syntax, semantics and sentiment of text data with the power of Python! This repository contains code and datasets used in my book, "Text Analytics with Python" published by Apress/Springer.
Stars: ✭ 1,132 (+362.04%)
Mutual labels:  natural-language-processing, natural-language
Sherlock
Natural-language event parser for Javascript
Stars: ✭ 393 (+60.41%)
Mutual labels:  datetime, natural-language-processing
Cogcomp Nlp
CogComp's Natural Language Processing libraries and Demos:
Stars: ✭ 410 (+67.35%)
Mutual labels:  natural-language-processing, natural-language
Pytextrank
Python implementation of TextRank for phrase extraction and summarization of text documents
Stars: ✭ 1,675 (+583.67%)
Mutual labels:  natural-language-processing, natural-language
Node Geo Tz
A node.js module to find the timezone based on gps coordinates
Stars: ✭ 181 (-26.12%)
Mutual labels:  datetime, timezone

What is SoulverCore?

SoulverCore is a math engine that evaluates day-to-day mathematical expressions. SoulverCore comes with sensible defaults and is also extremely customizable, with support for custom variables, units, functions and more.

Can I rely on SoulverCore for my project?

SoulverCore is the math engine from the popular notepad calculator app Soulver. Soulver has been available on Apple's platforms since 2005.

Soulver uses the exact same version of SoulverCore that is available to you here. As such, you can be confident that it will be maintained to support the latest versions of Apple's operating systems & hardware architectures.

Additionally, SoulverCore has been designed to have no 3rd party dependencies. It is written in 100% Swift.

Explore Soulver's documentation for information about the kinds of expressions supported by SoulverCore. And download Soulver itself and play around.

Licence

You may use SoulverCore in personal or private projects. Please email us if you wish to use SoulverCore in a publicly available, or commercial project. We have various options available depending on your needs, including a free (with attribution) license.

Apps using SoulverCore

  • Lacona - a powerful natural language assistant/launcher for macOS
  • Toolbox Pro - calculate with Soulver as part of your Siri Shortcuts on iOS

Requirements

  • Xcode 11+
  • Swift 5+
  • macOS 10.14.4+ (Intel or Apple Silicon) or iOS/iPadOS 12.2+

Swift Package Manager Support

Xcode 12 and later lets you integrate SoulverCore into your project using the Swift Package Manager.

In Xcode, go File > Swift Packages > Add Package Dependency and paste in the URL of this repository (https://github.com/soulverteam/SoulverCore).

Carthage Support

SoulverCore supports Carthage. Add the following binary dependency to your Cartfile:

binary "https://soulver.app/core/SoulverCore.json"

Manual Installation

Drag SoulverCore.xcframework into the Frameworks, Libraries, and Embedded Content section of the General settings for your Mac or iOS target.

Getting Started

To calculate the result of a single expression, use a Calculator object:

import SoulverCore

let calculator = Calculator(customization: .standard)
let result = calculator.evaluate("123 + 456")
print("The answer is \(result.stringValue)") // prints 579

SoulverCore can perform all sorts of calculations, including unit conversions, date & calendar math, rate calculations, percentage phrase functions, time zone conversions, and much more. It also cleverly ignores "meaningless" words:

calculator.evaluate("$10 for lunch + 15% tip") // $11.50
calculator.evaluate("65 kg in pounds") // 154.32 lb
calculator.evaluate("40 as % of 90") // 25%
calculator.evaluate("$150 is 25% on what") // $120
calculator.evaluate("$25/hour * 14 hours of work") // $350.00
calculator.evaluate("January 30 2020 + 3 months 2 weeks 5 days") // 19 May
calculator.evaluate("9:35am in New York to Japan") // 10:35 pm
calculator.evaluate("$25k over 10 years at 7.5%") // $51,525.79 (compound interest)

Output Formatting

Use a FormattingPreferences to customize the way your result is formatted (how many decimal places to include, should the thousands separator be inserted, etc).

var formattingPreferences = FormattingPreferences()
formattingPreferences.dp = 2 // decimal places
calculator.formattingPreferences = formattingPreferences

calculator.calculate("π") // 3.14

Variables

Use a VariableList to set values for words or phrases in your expression:

let variableList = VariableList(variables:
    [
        Variable(name: "a", value: "123"),
        Variable(name: "b", value: "456"),
    ]
)
calculator.evaluate("a + b", with: variableList) // 579        

Custom Units

You can add custom units to an EngineCustomization object required by the intializer on Calculator or LineCollection.

/// A good omakase EngineCustomization (the same used by Soulver.app)
var customization: EngineCustomization = .standard

/// Set an array of custom units defined in terms of an existing unit in SoulverCore
customization.customUnits = [
    CustomUnit(name: "parrots", definition: 15, equivalentUnit: .centimeters),
    CustomUnit(name: "python", definition: 570, equivalentUnit: .centimeters)
]

/// Create a Calculator using this customization
let calculator = Calculator(customization: customization)

/// python and parrots are now recognized as units
calculator.calculate("1 python in parrots") // 38 parrots

Locale Settings

SoulverCore respects the decimal separator and thousands separator of the system locale. Alternatively, you can convert the standard EngineCustomization to another locale:

let europeanLocale = Locale(identifier: "en_DE")
let localizedCustomization = EngineCustomization.standard.convertTo(locale: europeanLocale)

let calculator = Calculator(customization: localizedCustomization)

 /// In Germany a comma is used as a decimal separator
calculator.calculate("1,2 + 3,4") // 4,6

Multi-line Calculations

Use a LineCollection to represent a collection of lines to be evaluated. Like Calculator, you can customize the way a LineCollection interprets expressions with an EngineCustomization.

let multiLineText =
"""
a = 10
b = 20
c = a + b
"""
        
let lineCollection = LineCollection(multiLineText:
    multiLineText, customization: .standard)

/// Calculate the result of each line (synchronously)
lineCollection.evaluateAll()

/// Use subscripts to get access to particular lines' results
let result = lineCollection[2].result // 30

Currency Rates

The .standard EngineCustomization includes rates for 170 real-world currencies (that were accurate at the time the framework was last compiled).

You can (and should) update these currencies to the latest rates by setting valid API key credentials for CurrencyLayer (for fiat currencies) and Nomics (for crypto currencies) on the shared CurrencyList.

Alternatively use the .popular currency set to pull 33 common fiat currency rates from the European Central Bank, no API key required.

To fetch the latest rates, use SoulverCore's shared CurrencyList:

/// 33 popular currencies from the ECB, updated every weekday.

CurrencyList.shared.defaultCurrencySet = .popular 

CurrencyList.shared.refreshRates { (success) in
	
	if success {  
		/// The standard customization will now have the latest currency rates applied		
		
		let calculator = Calculator(customization: .standard)
		let result = calculator.calculate("10 USD in EUR")  		
	}
	
}

Adding calculation capabilities to NSTextView/UITextView

Check out the SoulverTextKit sample project for an example of how to integrate the SoulverCore math engine into a standard text view.

Supported Languages

In addition to English, SoulverCore is fully localized into German 🇩🇪, Russian 🇷🇺, and simplified Chinese 🇨🇳. Support for romance languages (French, Spanish, etc) is planned for later in 2021.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].