General
This machine learning model tags English natural language queries relating to precious metals, quantities, weights, purities, and currencies. It handles a broad variety of units across geographical regions and time periods and can infer a variety of additional ones from context. It has support for metals, units, and currencies, in common formats (e.g. symbols, slangs, full names, etc.). This model can serve as a step in the process of developing a simple chatbot, as has been incorporated into HullBreach Studios' Loot Flipping. This initial version of the ML model was release with Loot Flipping Pro v6.0.0 in July 2024. (Later releases added support for more currencies and refined training data in both Loot Flipping Pro and Loot Flipping Lite.).
Type
- Natural Language
- Parts-of-Speech Tagger
- Conditional Random Field Algorithm
Trained Labels
- Currencies: AUD, BRL, CAD, EUR, GBP, MXN, USD
- Metals: gold, iridium, palladium, platinum, rhodium, ruthenium, silver, inference of base metals
- Purities: gold-filled, karat, millesimal, percentage, specific ("dental", "fine", "pure", "ster", "sterling")
- Quantities: integers, decimals, several written forms, indefinite articles
- Units: ancient (drachma, shekel, tael), avoisdupois/imperial, carat, metric, troy, broad ranges
Formatting and Samples
- Input format: Lowercase with punctuation stripped
- Possible tagged labels:
CURRENCY
,METAL
,PURITY
,QUANTITY
,UNIT
, andNONE
- Example labels:
- what's (
NONE
) the (NONE
) value (NONE
) of (NONE
) 25.2 (QUANTITY
) dwt (UNIT
) of (NONE
) 14kt (PURITY
) gold (METAL
) - how (
NONE
) much (NONE
) for (NONE
) iridium (METAL
) per (NONE
) troy (UNIT
) ounce (UNIT
) in (NONE
) usd (CURRENCY
) - spot (
NONE
) price (NONE
) of (NONE
) sterling (PURITY
) silver (METAL
) - five (
QUANTITY
) ozt (UNIT
) platinum (METAL
) coins (NONE
) - 85 (
QUANTITY
) grams (UNIT
) of (NONE
) 14/20 (PURITY
) gold-filled (METAL
) in (NONE
) euros (CURRENCY
) - 2 (
QUANTITY
) pounds (UNIT
) sterling (PURITY
) silver (METAL
) in (NONE
) pounds (CURRENCY
) sterling (CURRENCY
)
- what's (
Usage (Swift)
import NaturalLanguage let inputText = "" if let mlModel = try? MetalSpot(configuration: MLModelConfiguration()).model, let metalSpotModel = try? NLModel(mlModel: mlModel) { let tagger = NLTagger(tagSchemes: [NLTagScheme("PriceBot")]) tagger.string = inputText.lowercased() tagger.setModels([metalSpotModel], forTagScheme: NLTagScheme("PriceBot")) let tags = tagger.tags(in: inputText.startIndex..<inputText.endIndex, unit: .word, scheme: NLTagScheme("PriceBot"), options: [.omitWhitespace, .omitPunctuation, .joinContractions]).map({ tag, range in return ["word": String(inputText[range]), "tag": tag?.rawValue ?? ""] }).filter({ $0["tag"] != "NONE" }) }