Git Product home page Git Product logo

vmware-archive / date-and-time-pattern-detection Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 2.0 199 KB

Date/time Pattern Detection is multi-module project consisting of library, rest-api and models. The project aims to help Engineers who need to parse date/time input without pattern, need validation library for localized date/time or help/suggestions on what are the standard Unicode practices for Localization.

License: Other

Dockerfile 0.09% Java 99.91%

date-and-time-pattern-detection's Introduction

Date/Time Pattern Detection Overview

Pattern Detection service provides utility for Engineers to verify and convert localized inputs containing dates, time and temporal values. The service is using Unicode Common Locale Data Repository (CLDR) to process and validate the localized date/time components. It provides suggestions based on the user input and Unicode standards.

Prerequisites

  • Git
  • Java 17 recommended (Any version after 8 may be used)
  • Maven
  • Docker (optional, depending on the build type)

Build and Run as local REST-API service using Docker

  1. Pull Docker image from GitHub Container Registry: docker pull ghcr.io/vmware-labs/date-and-time-pattern-detection:main If you get authentication error, you may need to login to chcr.io/vware-labs using Github username and access token.
  2. Run on specified port. Example: docker run -p 8083:8083 ghcr.io/vmware-labs/date-and-time-pattern-detection:main
  3. Open browser at http://localhost:8083/i18n/swagger-ui/index.html#/ (Port may be different, depending on above step).
  4. Access the REST-API documentation and test-out the endpoints.

Note: You can also run the service locally by cloning the project, calling mvn clean install and running the Jar file under rest-api-service/target/.

Example Usage

You can either validate localized input containing Dates, times and more temporal types, get CLDR standard patterns or convert localized input from 1 language to another. Sample request for input validation:

curl -X POST "http://localhost:8083/i18n/validate/localizedInput/en-US" -H "accept: */*" -H "Content-Type: application/json" -d "Monday, 25 July, 2022 at 8:14 in the morning"

Sample response for input validation:

{
  "isLocalizedContent": true,
  "detectedPattern": {
    "pattern": "EEEE, d MMMM, yyyy 'at' h:mm B",
    "isStandardFormat": false,
    "isValidDate": true,
    "patternInfoMessage": "The input is valid and non-standard localized date+time."
  },
  "language": "English (United States)",
  "input": "Monday, 25 July, 2022 at 8:14 in the morning",
  "suggestions": {
    "NON_STANDARD_DATE_TIME": "Provided dateTime does not match the standard CLDR dateTime patterns: [M/d/yy, h:mm a, MMM d, y, h:mm:ss a, MMMM d, y 'at' h:mm:ss a z, EEEE, MMMM d, y 'at' h:mm:ss a zzzz]"
  },
  "errors": {}
}

Using the project as Maven Dependency

You can directly use the library part of the project by injecting the dependency in your project.

  1. Add the dependency in your Maven pom.xml file:
<dependency>
  <groupId>com.vmware.g11n</groupId>
  <artifactId>date-time-pattern-detection-library</artifactId>
  <version>1.0.2</version>
</dependency>
  1. Specify GitHub Package Registry as Maven Repository in your local settings.xml:
<repositories>
    <repository>
        <id>github</id>
        <name>GitHub VMware Apache Maven Packages</name>
        <url>https://maven.pkg.github.com/vmware-labs/date-and-time-pattern-detection</url>
    </repository>
</repositories>
  1. Run mvn clean install to inject the dependencies
  2. Access all functionality by initializing Pattern Detection object:
DateTimePatternDetection patternDetection = new DateTimePatternDetection();
ValidationResult validationResult = patternDetection.validateLocalizedInput("2016년 9월 1일 목요일 AM 11시 7분 10초 그리니치 표준시", "ko-KR");

As the project is multi-module, you can only use the service models for mapping response objects from the Rest-API service (may be useful for using the project in test frameworks).

Contributing

The date-and-time-pattern-detection project team welcomes contributions from the community. Before you start working with date-and-time-pattern-detection, please read our Developer Certificate of Origin. All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to CONTRIBUTING.md.

date-and-time-pattern-detection's People

Contributors

kirilraykov avatar vmwghbot avatar dependabot[bot] avatar

Stargazers

 avatar Georgi Lambov avatar JESSIELY JUACHON avatar  avatar Raymond peng avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Qiang Wan avatar

Watchers

Qiang Wan avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.