665ad11bf9
Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.13.4.1 to 2.13.4.2. - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
---|---|---|
.. | ||
libraries | ||
samples | ||
tests | ||
.gitignore | ||
README.md | ||
build-resources.cmd | ||
build-resources.sh | ||
build.ci.cmd | ||
build.cmd | ||
linting-excluded-files.xml | ||
linting-rules.xml | ||
pom.xml | ||
tests.ci.cmd |
README.md
Microsoft.Recognizers.Text for Java
Getting Started
Recognizer's are organized into groups and designed to be used in C#, Node.js, Python and Java to help you build great applications! To use the samples clone our GitHub repository using Git.
Cloning and building the Repository
git clone https://github.com/Microsoft/Recognizers-Text.git
cd Recognizers-Text
You can between build the solution manually using Maven.
Manual Build and installation on local Maven folder (.m2)
Open a terminal and run the following commands:
cd Java
mvn clean install
Installation
Install Recognizer's by adding the following dependencies in your pom.xml
:
-
Get core Recognizer's features:
<dependency> <groupId>com.microsoft.recognizers.text</groupId> <artifactId>recognizers-text</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
-
Get numbers Recognizer's features:
<dependency> <groupId>com.microsoft.recognizers.text.number</groupId> <artifactId>recognizers-text-number</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
-
Get numbers with units Recognizer's features:
<dependency> <groupId>com.microsoft.recognizers.text.numberwithunit</groupId> <artifactId>recognizers-text-number-with-unit</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
-
Get datetime Recognizer's features:
<dependency> <groupId>com.microsoft.recognizers.text.datetime</groupId> <artifactId>recognizers-text-date-time</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
-
Get sequence Recognizer's features:
<dependency> <groupId>com.microsoft.recognizers.text.sequence</groupId> <artifactId>recognizers-text-sequence</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
-
Get choice Recognizer's features:
<dependency> <groupId>com.microsoft.recognizers.text.choice</groupId> <artifactId>recognizers-text-choice</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
API Documentation
Once the proper modules are installed, you'll need to import the modules:
import com.microsoft.recognizers.text.Culture;
import com.microsoft.recognizers.text.IModel;
import com.microsoft.recognizers.text.ModelResult;
import com.microsoft.recognizers.text.number.NumberRecognizer;
import com.microsoft.recognizers.text.numberwithunit.NumberWithUnitRecognizer;
Recognizer's Models
This is the preferred way if you need to parse multiple inputs based on the same context (e.g.: language and options):
NumberRecognizer recognizer = new NumberRecognizer(Culture.English);
IModel model = recognizer.getNumberModel();
List<ModelResult> result = model.parse("Twelve");
Or, for less verbosity, you use the helper methods:
List<ModelResult> result = NumberRecognizer.recognizeNumber("Twelve", Culture.English);
Internally, both methods will cache the instance models to avoid extra costs.
com.microsoft.recognizers.text.number
-
Numbers
This recognizer will find any number from the input. E.g. "I have two apples" will return "2".
NumberRecognizer.recognizeNumber("I have two apples", Culture.English)
Or you can obtain a model instance using:
new NumberRecognizer(Culture.English).getNumberModel()
-
Ordinal Numbers
This recognizer will find any ordinal number. E.g. "eleventh" will return "11".
NumberRecognizer.recognizeOrdinal("eleventh", Culture.English)
Or you can obtain a model instance using:
new NumberRecognizer(Culture.English).getOrdinalModel()
-
Percentages
This recognizer will find any number presented as percentage. E.g. "one hundred percents" will return "100%".
NumberRecognizer.recognizePercentage("one hundred percents", Culture.English)
Or you can obtain a model instance using:
new NumberRecognizer(Culture.English).getPercentageModel()
com.microsoft.recognizers.text.numberwithunit
-
Ages
This recognizer will find any age number presented. E.g "After ninety five years of age, perspectives change" will return "95 Year".
NumberWithUnitRecognizer.recognizeAge("After ninety five years of age, perspectives change", Culture.English)
Or you can obtain a model instance using:
new NumberWithUnitRecognizer(Culture.English).getAgeModel()
-
Currencies
This recognizer will find any currency presented. E.g "Interest expense in the 1988 third quarter was $ 75.3 million" will return "75300000 Dollar".
NumberWithUnitRecognizer.recognizeCurrency("Interest expense in the 1988 third quarter was $ 75.3 million", Culture.English)
Or you can obtain a model instance using:
new NumberWithUnitRecognizer(Culture.English).getCurrencyModel()
-
Dimensions
This recognizer will find any dimension presented. E.g "The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours." will return "6 Mile".
NumberWithUnitRecognizer.recognizeDimension("The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours.", Culture.English)
Or you can obtain a model instance using:
new NumberWithUnitRecognizer(Culture.English).getDimensionModel()
-
Temperatures
This recognizer will find any temperature presented. E.g "Set the temperature to 30 degrees celsius" will return "30 C".
NumberWithUnitRecognizer.recognizeTemperature("Set the temperature to 30 degrees celsius", Culture.English)
Or you can obtain a model instance using:
new NumberWithUnitRecognizer(Culture.English).getTemperatureModel()
Samples
Integration tips
The recognizers were designed to disjoint language's logic from the recognizer's core in order to grow without the obligation of change the supported platforms.
To achieve this, the recognizers contains the following folders:
- Specs - Contains all the necessary tests that should be run on any improvements to the recognizers. It's divided by recognizer and supported language.
- Patterns - Contains all the regular expressions that fulfill the recognizers logic. It's divided by supported language.
Linting rules
This project uses linting rules to enforce code standardization. These rules are specified in the file linting-rules.xml with CheckStyle and are hooked to Maven's build cycle.
INFO: Since the CheckStyle plugin is hook to the build cycle, this makes the build fail in case there are linting warnings in the project files so be sure to check that the code doesn't break any rule.
CheckStyle is available in different flavours:
INFO: Be sure to configure your IDE to use the file linting-rules.xml instead of the default rules.