diff --git a/Java/libraries/recognizers-text-choice/pom.xml b/Java/libraries/recognizers-text-choice/pom.xml new file mode 100644 index 0000000000..7fdb022edb --- /dev/null +++ b/Java/libraries/recognizers-text-choice/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + + com.microsoft.recognizers.text.choice + recognizers-text-choice + 1.0-SNAPSHOT + jar + + ${project.groupId}:${project.artifactId} + Microsoft.Recognizers.Text - Choice Recognizers + https://github.com/Microsoft/Recognizers-Text/ + + + com.microsoft.recognizers.text + recognizers-text-java + 1.0-SNAPSHOT + ../../ + + + + + MIT License + http://www.opensource.org/licenses/mit-license.php + + + + + + Microsoft Recognizers-Text + + Microsoft + https://www.microsoft.com/ + + + + UTF-8 + + + + com.microsoft.recognizers.text + recognizers-text + 1.0-SNAPSHOT + + + com.google.guava + guava + 24.1-jre + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/resource-definitions.json b/Java/libraries/recognizers-text-choice/resource-definitions.json new file mode 100644 index 0000000000..d85490ec03 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/resource-definitions.json @@ -0,0 +1,80 @@ +{ + "outputPath": "libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/", + "configFiles": [ + { + "input": [ + "English", + "English-Choice" + ], + "output": "EnglishChoice", + "header": [ + "package com.microsoft.recognizers.text.choice.resources;", + "", + "public class EnglishChoice {" + ], + "footer": [ + "}" + ] + }, + { + "input": [ + "Spanish", + "Spanish-Choice" + ], + "output": "SpanishChoice", + "header": [ + "package com.microsoft.recognizers.text.choice.resources;", + "", + "public class SpanishChoice {" + ], + "footer": [ + "}" + ] + }, + { + "input": [ + "Portuguese", + "Portuguese-Choice" + ], + "output": "PortugueseChoice", + "header": [ + "package com.microsoft.recognizers.text.choice.resources;", + "", + "public class PortugueseChoice {" + ], + "footer": [ + "}" + ] + }, + { + "input": [ + "Chinese", + "Chinese-Choice" + ], + "output": "ChineseChoice", + "header": [ + "package com.microsoft.recognizers.text.choice.resources;", + "", + "public class ChineseChoice {" + ], + "footer": [ + "}" + ] + }, + { + "input": [ + "French", + "French-Choice" + ], + "output": "FrenchChoice", + "header": [ + "package com.microsoft.recognizers.text.choice.resources;", + "", + "public class FrenchChoice {" + ], + "footer": [ + "}" + ] + } + ] +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/ChoiceOptions.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/ChoiceOptions.java new file mode 100644 index 0000000000..1a382b42ee --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/ChoiceOptions.java @@ -0,0 +1,5 @@ +package com.microsoft.recognizers.text.choice; + +public enum ChoiceOptions { + None +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/ChoiceRecognizer.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/ChoiceRecognizer.java new file mode 100644 index 0000000000..eeaf7787ad --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/ChoiceRecognizer.java @@ -0,0 +1,64 @@ +package com.microsoft.recognizers.text.choice; + +import java.util.List; +import com.microsoft.recognizers.text.IModel; +import com.microsoft.recognizers.text.ModelResult; +import com.microsoft.recognizers.text.Recognizer; + +public class ChoiceRecognizer extends Recognizer { + + public ChoiceRecognizer(String targetCulture, ChoiceOptions options, + boolean lazyInitialization) { + super(targetCulture, options, lazyInitialization); + } + + public ChoiceRecognizer(String targetCulture, int options, boolean lazyInitialization) { + this(targetCulture, ChoiceOptions.values()[options], lazyInitialization); + } + + public ChoiceRecognizer(int options, boolean lazyInitialization) { + this(null, ChoiceOptions.values()[options], lazyInitialization); + } + + public ChoiceRecognizer(ChoiceOptions options, boolean lazyInitialization) { + this(null, options, lazyInitialization); + } + + public ChoiceRecognizer(boolean lazyInitialization) { + this(null, ChoiceOptions.None, lazyInitialization); + } + + public ChoiceRecognizer(int options) { + this(null, ChoiceOptions.values()[options], true); + } + + public ChoiceRecognizer(ChoiceOptions options) { + this(null, options, true); + } + + public ChoiceRecognizer() { + this(null, ChoiceOptions.None, true); + } + + public IModel GetBooleanModel(String culture, boolean fallbackToDefaultCulture) { + throw new UnsupportedOperationException(); + // return GetModel(culture, fallbackToDefaultCulture); + } + + public static List RecognizeBoolean(String query, String culture, ChoiceOptions options, boolean fallbackToDefaultCulture) { + throw new UnsupportedOperationException(); + } + + public static List RecognizeBoolean(String query, String culture, ChoiceOptions options) { + return RecognizeBoolean(query, culture, options, true); + } + + public static List RecognizeBoolean(String query, String culture) { + return RecognizeBoolean(query, culture, ChoiceOptions.None); + } + + @Override + protected void initializeConfiguration() { + throw new UnsupportedOperationException(); + } +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/Constants.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/Constants.java new file mode 100644 index 0000000000..d15322850a --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/Constants.java @@ -0,0 +1,8 @@ +package com.microsoft.recognizers.text.choice; + +public class Constants { + public static final String SYS_BOOLEAN_TRUE = "boolean_true"; + public static final String SYS_BOOLEAN_FALSE = "boolean_false"; + // Model type name + public static final String MODEL_BOOLEAN = "boolean"; +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/config/BooleanParserConfiguration.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/config/BooleanParserConfiguration.java new file mode 100644 index 0000000000..1b02ee5e70 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/config/BooleanParserConfiguration.java @@ -0,0 +1,12 @@ +package com.microsoft.recognizers.text.choice.config; + +import java.util.Dictionary; + +public class BooleanParserConfiguration implements IChoiceParserConfiguration { + public Dictionary Resolutions; + + @Override + public Dictionary getResolutions() { + return this.Resolutions; + } +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/config/IChoiceParserConfiguration.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/config/IChoiceParserConfiguration.java new file mode 100644 index 0000000000..763201ab77 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/config/IChoiceParserConfiguration.java @@ -0,0 +1,7 @@ +package com.microsoft.recognizers.text.choice.config; + +import java.util.Dictionary; + +public interface IChoiceParserConfiguration { + public Dictionary getResolutions(); +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/BooleanExtractor.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/BooleanExtractor.java new file mode 100644 index 0000000000..8c8b6bdf3a --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/BooleanExtractor.java @@ -0,0 +1,7 @@ +package com.microsoft.recognizers.text.choice.extractors; + +public class BooleanExtractor extends ChoiceExtractor { + public BooleanExtractor(IBooleanExtractorConfiguration config) { + super(config); + } +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/ChoiceExtractor.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/ChoiceExtractor.java new file mode 100644 index 0000000000..cacb9704ff --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/ChoiceExtractor.java @@ -0,0 +1,42 @@ +package com.microsoft.recognizers.text.choice.extractors; + +import java.util.ArrayList; +import java.util.List; + +import com.microsoft.recognizers.text.ExtractResult; +import com.microsoft.recognizers.text.IExtractor; + +public class ChoiceExtractor implements IExtractor { + + private IChoiceExtractorConfiguration config; + + public ChoiceExtractor(IChoiceExtractorConfiguration config) { + this.config = config; + } + + @Override + public List extract(String text) { + throw new UnsupportedOperationException(); + } + + private final double MatchValue(List source, List match, int startPosition) { + double matched = 0; + return matched; + } + + private static int IndexOfToken(List tokens, String token, int startPos) { + return 0; + } + + private final List Tokenize(String text) { + return new ArrayList<>(); + } +} +class ChoiceExtractDataResult { + + public final List OtherMatches = new ArrayList<>(); + + public final String Source = ""; + + public final double Score = 0; +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/IBooleanExtractorConfiguration.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/IBooleanExtractorConfiguration.java new file mode 100644 index 0000000000..2732d561de --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/IBooleanExtractorConfiguration.java @@ -0,0 +1,9 @@ +package com.microsoft.recognizers.text.choice.extractors; + +import java.util.regex.Pattern; + +public interface IBooleanExtractorConfiguration extends IChoiceExtractorConfiguration { + public Pattern getTrueRegex(); + + public Pattern getFalseRegex(); +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/IChoiceExtractorConfiguration.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/IChoiceExtractorConfiguration.java new file mode 100644 index 0000000000..13fb9de84c --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/extractors/IChoiceExtractorConfiguration.java @@ -0,0 +1,16 @@ +package com.microsoft.recognizers.text.choice.extractors; + +import java.util.Dictionary; +import java.util.regex.Pattern; + +public interface IChoiceExtractorConfiguration { + public Dictionary MapRegexes(); + + public Pattern getTokenRegex(); + + public boolean getAllowPartialMatch(); + + public int getMaxDistance(); + + public boolean getOnlyTopMatch(); +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/models/BooleanModel.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/models/BooleanModel.java new file mode 100644 index 0000000000..ed7c5dd043 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/models/BooleanModel.java @@ -0,0 +1,24 @@ +package com.microsoft.recognizers.text.choice.models; + +import java.util.Map; + +import com.microsoft.recognizers.text.IExtractor; +import com.microsoft.recognizers.text.IParser; +import com.microsoft.recognizers.text.ParseResult; +import com.microsoft.recognizers.text.choice.Constants; + +public class BooleanModel extends ChoiceModel { + + public BooleanModel(IParser parser, IExtractor extractor) { + super(parser, extractor); + throw new UnsupportedOperationException(); + } + + public String getModelTypeName() { + return Constants.MODEL_BOOLEAN; + } + + protected Map GetResolution(ParseResult parseResult) { + throw new UnsupportedOperationException(); + } +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/models/ChoiceModel.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/models/ChoiceModel.java new file mode 100644 index 0000000000..5d5dbc1f50 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/models/ChoiceModel.java @@ -0,0 +1,35 @@ +package com.microsoft.recognizers.text.choice.models; + +import java.util.List; +import java.util.Map; + +import com.microsoft.recognizers.text.IExtractor; +import com.microsoft.recognizers.text.IModel; +import com.microsoft.recognizers.text.IParser; +import com.microsoft.recognizers.text.ModelResult; +import com.microsoft.recognizers.text.ParseResult; +import com.microsoft.recognizers.text.choice.Constants; + +public class ChoiceModel implements IModel { + protected IExtractor Extractor; + protected IParser Parser; + + public ChoiceModel(IParser parser, IExtractor extractor) { + this.Parser = parser; + this.Extractor = extractor; + } + + @Override + public String getModelTypeName() { + return Constants.MODEL_BOOLEAN; + } + + @Override + public List parse(String query) { + throw new UnsupportedOperationException(); + } + + protected Map GetResolution(ParseResult parseResult) { + throw new UnsupportedOperationException(); + } +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/BooleanParser.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/BooleanParser.java new file mode 100644 index 0000000000..800d127d71 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/BooleanParser.java @@ -0,0 +1,10 @@ +package com.microsoft.recognizers.text.choice.parsers; + +import com.microsoft.recognizers.text.choice.config.BooleanParserConfiguration; + +public class BooleanParser extends OptionsParser { + public BooleanParser() { + super(new BooleanParserConfiguration()); + throw new UnsupportedOperationException(); + } +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsOtherMatchParseResult.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsOtherMatchParseResult.java new file mode 100644 index 0000000000..1db6376e1e --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsOtherMatchParseResult.java @@ -0,0 +1,7 @@ +package com.microsoft.recognizers.text.choice.parsers; + +public class OptionsOtherMatchParseResult { + public final double Score = 0; + public final String Text = ""; + public final Object Value = null; +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsParseDataResult.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsParseDataResult.java new file mode 100644 index 0000000000..74b3bf634e --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsParseDataResult.java @@ -0,0 +1,9 @@ +package com.microsoft.recognizers.text.choice.parsers; + +import java.util.ArrayList; +import java.util.List; + +public class OptionsParseDataResult { + public final double Score = 0; + public final List OtherMatches = new ArrayList<>(); +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsParser.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsParser.java new file mode 100644 index 0000000000..f6307d4ab5 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/parsers/OptionsParser.java @@ -0,0 +1,23 @@ +package com.microsoft.recognizers.text.choice.parsers; + +import com.microsoft.recognizers.text.ExtractResult; +import com.microsoft.recognizers.text.ParseResult; +import com.microsoft.recognizers.text.IParser; +import com.microsoft.recognizers.text.choice.config.IChoiceParserConfiguration; + +public class OptionsParser implements IParser { + + private IChoiceParserConfiguration config; + + public OptionsParser(IChoiceParserConfiguration config) { + this.config = config; + } + + public ParseResult parse(ExtractResult extractResult) { + throw new UnsupportedOperationException(); + } + + private OptionsOtherMatchParseResult TOptionsOtherMatchReuslt(ExtractResult extractResult) { + throw new UnsupportedOperationException(); + } +} \ No newline at end of file diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/ChineseChoice.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/ChineseChoice.java new file mode 100644 index 0000000000..95230ac2c8 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/ChineseChoice.java @@ -0,0 +1,20 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +package com.microsoft.recognizers.text.choice.resources; + +public class ChineseChoice { + + public static final String LangMarker = "Chs"; + + public static final String TokenizerRegex = "[^\\u3040-\\u30ff\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\uff66-\\uff9f]"; + + public static final String TrueRegex = "(好[的啊呀嘞哇]|没问题|可以|中|好|同意|行|是的|是|对)|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)"; + + public static final String FalseRegex = "(不行|不好|拒绝|否定|不中|不可以|不是的|不是|不对|不)|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)"; +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/EnglishChoice.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/EnglishChoice.java new file mode 100644 index 0000000000..ecbbeca639 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/EnglishChoice.java @@ -0,0 +1,20 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +package com.microsoft.recognizers.text.choice.resources; + +public class EnglishChoice { + + public static final String LangMarker = "Eng"; + + public static final String TokenizerRegex = "[^\\w\\d]"; + + public static final String TrueRegex = "\\b(true|yes|yep|y|sure|ok|agree)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)"; + + public static final String FalseRegex = "\\b(false|nope|nop|no|not\\s+ok|disagree)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)"; +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/FrenchChoice.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/FrenchChoice.java new file mode 100644 index 0000000000..d090ea60c6 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/FrenchChoice.java @@ -0,0 +1,20 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +package com.microsoft.recognizers.text.choice.resources; + +public class FrenchChoice { + + public static final String LangMarker = "Fr"; + + public static final String TokenizerRegex = "[^\\w\\d\\u00E0-\\u00FC]"; + + public static final String TrueRegex = "\\b(s[uû]r|ouais|oui|yep|y|sure|approuver|accepter|consentir|d'accord|ça march[eé])\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)"; + + public static final String FalseRegex = "\\b(faux|nan|non|pas\\s+d'accord|pas\\s+concorder|n'est\\s+pas\\s+(correct|ok)|pas)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)"; +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/PortugueseChoice.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/PortugueseChoice.java new file mode 100644 index 0000000000..d0b21e0b60 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/PortugueseChoice.java @@ -0,0 +1,20 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +package com.microsoft.recognizers.text.choice.resources; + +public class PortugueseChoice { + + public static final String LangMarker = "Por"; + + public static final String TokenizerRegex = "[^\\w\\d\\u00E0-\\u00FC]"; + + public static final String TrueRegex = "\\b(verdade|verdadeir[oa]|sim|isso|claro|ok)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)"; + + public static final String FalseRegex = "\\b(falso|n[aã]o|incorreto|nada disso)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)"; +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/SpanishChoice.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/SpanishChoice.java new file mode 100644 index 0000000000..6fe2907606 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/resources/SpanishChoice.java @@ -0,0 +1,20 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +package com.microsoft.recognizers.text.choice.resources; + +public class SpanishChoice { + + public static final String LangMarker = "Spa"; + + public static final String TokenizerRegex = "[^\\w\\d\\u00E0-\\u00FC]"; + + public static final String TrueRegex = "\\b(verdad|verdadero|sí|sip|s|si|cierto|por supuesto|ok)\\b|(\\uD83D\\uDC4D|\\uD83D\\uDC4C)"; + + public static final String FalseRegex = "\\b(falso|no|nop|n|no)\\b|(\\uD83D\\uDC4E|\\u270B|\\uD83D\\uDD90)"; +} diff --git a/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/utilities/UnicodeUtils.java b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/utilities/UnicodeUtils.java new file mode 100644 index 0000000000..069d0bbf94 --- /dev/null +++ b/Java/libraries/recognizers-text-choice/src/main/java/com/microsoft/recognizers/text/choice/utilities/UnicodeUtils.java @@ -0,0 +1,29 @@ +package com.microsoft.recognizers.text.choice.utilities; + +import java.lang.Character; +import java.util.ArrayList; +import java.util.List; + +public class UnicodeUtils { + public static boolean IsEmoji(String letter) { + final int WhereEmojiLive = 0xFFFF; // Supplementary Unicode Plane. This is where emoji live + return Character.isHighSurrogate(letter.charAt(0)) && (letter.codePointAt(0) > WhereEmojiLive); + } + + public static List Letters(String text) { + char codePoint = 0; + List result = new ArrayList<>(); + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + if (codePoint != 0) { + result.add(Character.toString(codePoint)); + codePoint = 0; + } else if (!Character.isHighSurrogate(c)) { + result.add(Character.toString(c)); + } else { + codePoint = c; + } + } + return result; + } +} \ No newline at end of file diff --git a/Java/libraries/resource-generator/pom.xml b/Java/libraries/resource-generator/pom.xml index 9804975ee7..6a9a548b20 100644 --- a/Java/libraries/resource-generator/pom.xml +++ b/Java/libraries/resource-generator/pom.xml @@ -59,6 +59,7 @@ libraries/recognizers-text-number/resource-definitions.json libraries/recognizers-text-number-with-unit/resource-definitions.json + libraries/recognizers-text-choice/resource-definitions.json libraries/recognizers-text-date-time/resource-definitions.json diff --git a/Java/pom.xml b/Java/pom.xml index 9542e75301..b19158c960 100644 --- a/Java/pom.xml +++ b/Java/pom.xml @@ -18,6 +18,7 @@ libraries/recognizers-text libraries/recognizers-text-number libraries/recognizers-text-number-with-unit + libraries/recognizers-text-choice libraries/recognizers-text-date-time tests samples/simple-console