Example usage for java.util Locale ITALIAN

List of usage examples for java.util Locale ITALIAN

Introduction

In this page you can find the example usage for java.util Locale ITALIAN.

Prototype

Locale ITALIAN

To view the source code for java.util Locale ITALIAN.

Click Source Link

Document

Useful constant for language.

Usage

From source file:eu.trentorise.opendata.semtext.jackson.test.SemTextModuleTest.java

@Test
public void testMeaning() throws IOException {
    SemTextModule.registerMetadata(Meaning.class, "a", Dict.class);
    SemTextModule.registerMetadata(Meaning.class, "b", MyMetadata.class);

    registerMyMetadata();//from   w w  w . j av  a 2  s  .  c  om

    Meaning m1 = Meaning.of("a", MeaningKind.ENTITY, 0.2, Dict.of(Locale.ITALIAN, "a"),
            Dict.of(Locale.FRENCH, "b"), ImmutableMap.of("a", Dict.of("s"), "b", MyMetadata.of("hello")));
    OdtJacksonTester.testJsonConv(objectMapper, LOG, m1);
}

From source file:eu.trentorise.opendata.semtext.jackson.test.SemTextModuleTest.java

@Test
public void testTerm() throws IOException {
    SemTextModule.registerMetadata(Meaning.class, "a", Dict.class);
    Meaning m1 = Meaning.of("a", MeaningKind.ENTITY, 0.2, Dict.of(Locale.ITALIAN, "a"),
            Dict.of(Locale.FRENCH, "b"), ImmutableMap.of("a", Dict.of("s")));
    testJsonConv(objectMapper, LOG, m1);
}

From source file:eu.trentorise.opendata.commons.test.jackson.TodCommonsModuleTest.java

@Test
public void example1() throws JsonProcessingException, IOException {

    ObjectMapper om = new ObjectMapper();
    om.registerModule(new GuavaModule());
    om.registerModule(new TodCommonsModule());

    String json = om.writeValueAsString(LocalizedString.of(Locale.ITALIAN, "ciao"));
    LocalizedString reconstructedLocalizedString = om.readValue(json, LocalizedString.class);
}

From source file:eu.trentorise.opendata.commons.test.jackson.TodCommonsModuleTest.java

@Test
public void example2() throws JsonProcessingException, IOException {

    ObjectMapper om = new ObjectMapper();
    TodCommonsModule.registerModulesInto(om);

    String json = om.writeValueAsString(LocalizedString.of(Locale.ITALIAN, "ciao"));
    LocalizedString reconstructedLocalizedString = om.readValue(json, LocalizedString.class);
}

From source file:org.talend.designer.core.ui.preferences.I18nPreferencePage.java

@Override
protected void createFieldEditors() {
    // Adds a combo for language selection.

    String spanish = "Espa\u00F1ol"; //$NON-NLS-1$
    byte[] utf8Bytes;
    try {//www  .j  a  va  2  s  . c  o  m
        utf8Bytes = spanish.getBytes("UTF8"); //$NON-NLS-1$
        spanish = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        spanish = "Spanish"; //$NON-NLS-1$
    }

    String russian = "\u0420\u0443\u0441\u0441\u043A\u0438\u0439"; //$NON-NLS-1$
    try {
        utf8Bytes = russian.getBytes("UTF8"); //$NON-NLS-1$
        russian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        russian = "Russian"; //$NON-NLS-1$
    }

    String greek = "\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"; //$NON-NLS-1$
    try {
        utf8Bytes = greek.getBytes("UTF8"); //$NON-NLS-1$
        greek = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        greek = "Greek"; //$NON-NLS-1$
    }

    String arabic = "\u0627\u0644\u0639\u0631\u0628\u064a\u0647"; //$NON-NLS-1$
    try {
        utf8Bytes = arabic.getBytes("UTF8"); //$NON-NLS-1$
        arabic = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        arabic = "Arabic"; //$NON-NLS-1$
    }

    String serbian = "\u0421\u0440\u043f\u0441\u043a\u0438"; //$NON-NLS-1$
    try {
        utf8Bytes = serbian.getBytes("UTF8"); //$NON-NLS-1$
        serbian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        serbian = "Serbian"; //$NON-NLS-1$
    }

    String[][] entryNamesAndValues = {
            { Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH), Locale.ENGLISH.getLanguage() },
            { Locale.FRENCH.getDisplayLanguage(Locale.FRENCH), Locale.FRENCH.getLanguage() },
            { Locale.CHINESE.getDisplayLanguage(Locale.CHINESE), "zh_CN" },
            { Locale.GERMAN.getDisplayLanguage(Locale.GERMAN), Locale.GERMAN.getLanguage() },
            { Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE), Locale.JAPANESE.getLanguage() },
            { Locale.ITALIAN.getDisplayLanguage(Locale.ITALIAN), Locale.ITALIAN.getLanguage() },
            { "Brasil", "pt_BR" }, //$NON-NLS-1$ //$NON-NLS-2$ 
            { spanish, "es" }, { russian, "ru" }, //$NON-NLS-1$ //$NON-NLS-2$ 
            { Locale.KOREA.getDisplayLanguage(Locale.KOREA), "kr" }, { "Turkish", "tr" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
            { greek, "el" }, { "Hrvatski", "hr" }, { arabic, "ar" }, { serbian, "sr" }, { "Polski", "pl" },
            { "Romanian", "ro" }, { "Netherlands", "nl" } }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // /$NON-NLS-7$ 
    languageSelectionEditor = new OneLineComboFieldEditor(ITalendCorePrefConstants.LANGUAGE_SELECTOR,
            Messages.getString("I18nPreferencePage.needRestart"), entryNamesAndValues, getFieldEditorParent()); //$NON-NLS-1$
    addField(languageSelectionEditor);

    Composite composite = getFieldEditorParent();
    LabelFieldEditor importAll = new LabelFieldEditor(
            Messages.getString("I18nPreferencePage.translationInformation"), //$NON-NLS-1$
            composite);
    addField(importAll);

    Button allUpdate = new Button(composite, SWT.FLAT);
    allUpdate.setText(Messages.getString("I18nPreferencePage.importBabili")); //$NON-NLS-1$
    allUpdate.setLayoutData(new GridData());

    allUpdate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // import all update from Babili
            // select the .zip file
            FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    SWT.OPEN);
            fd.setText("Open"); //$NON-NLS-1$
            fd.setFilterPath("C:" + fs); //$NON-NLS-1$
            String[] filterExtensions = { "*.zip" }; //$NON-NLS-1$
            fd.setFilterExtensions(filterExtensions);
            String selected = fd.open();
            if (selected != null) {
                isBabiliButtonClicked = true;
                runProgressMonitorDialog(selected);
                if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        Messages.getString("I18nPreferencePage.restart"), //$NON-NLS-1$
                        Messages.getString("I18nPreferencePage.restartButton"))) {
                    PlatformUI.getWorkbench().restart();
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // Nothing to do
        }
    });

    // added by nma
    Button restoredefault = new Button(composite, SWT.FLAT);
    restoredefault.setText("Restore Defaults"); //$NON-NLS-1$
    restoredefault.setLayoutData(new GridData());
    restoredefault.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // Nothing to do
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            isBabiliButtonClicked = true;
            runProgressMonitorDialog(Messages.getString("I18nPreferencePage.restoreDefault")); //$NON-NLS-1$
            if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.getString("I18nPreferencePage.restart"),
                    Messages.getString("I18nPreferencePage.restartButton"))) {
                PlatformUI.getWorkbench().restart();
            }
        }
    });
}

From source file:eu.trentorise.opendata.semtext.nltext.test.NLMetadataTest.java

/**
 * Serializes with Jackson a SemText with text "Town of Arco",
 * where term 'Arco' is tagged with meaning ENTITY but as other possible
 * meaning has 'bow'. Both term Arco and meanings have attached additional
 * metadata coming from nltext.//from  ww w.j ava  2s  .c om
 *
 */
@Test
public void jacksonExample() throws IOException {

    ObjectMapper objectMapper = new ObjectMapper();

    SemTextModule.registerModulesInto(objectMapper);

    SemTextModule.registerMetadata(Meaning.class, NLTextConverter.NLTEXT_NAMESPACE, NLMeaningMetadata.class);
    SemTextModule.registerMetadata(Term.class, NLTextConverter.NLTEXT_NAMESPACE, NLTermMetadata.class);

    NLTermMetadata nlTermMetadata = NLTermMetadata.of(ImmutableList.of("mystem1", "mystem2"),
            ImmutableList.of("myderived lemma 1", "myderived lemma 2"));
    String text = "Town of Arco";

    Meaning selectedMeaning = Meaning.builder().setId("123").setKind(MeaningKind.ENTITY).setProbability(0.2)
            .setName(Dict.builder().put(Locale.ITALIAN, "Comune di Arco").put(Locale.ENGLISH, "Arco town")
                    .build())
            .setDescription(Dict.of(Locale.ENGLISH, "A beatiful town in Trentino"))
            .setMetadata(ImmutableMap.of("nltext", NLMeaningMetadata.of("my lemma", "my summary"))).build();

    Meaning otherMeaning = Meaning.builder().setId("123").setKind(MeaningKind.CONCEPT).setProbability(0.2)
            .setName(Dict.builder().put(Locale.ITALIAN, "arco").put(Locale.ENGLISH, "bow").build())
            .setDescription(Dict.of(Locale.ENGLISH, "a weapon to be used with arrows"))

            .setMetadata(ImmutableMap.of("nltext", NLMeaningMetadata.of("my lemma", "my summary"))).build();

    Term term = Term.of(8, 12, MeaningStatus.SELECTED, selectedMeaning, ImmutableList.of(otherMeaning),
            ImmutableMap.of("nltext", nlTermMetadata));

    Sentence sentence = Sentence.of(0, 12, term);

    System.out.println(objectMapper.writeValueAsString(SemText.of(Locale.ENGLISH, text, sentence)));

}

From source file:eu.trentorise.opendata.semtext.jackson.test.SemTextModuleTest.java

@Test
public void testMetadataSemText() throws IOException {
    SemTextModule.registerMetadata(SemText.class, "a", MyMetadata.class);
    registerMyMetadata();/*from w  w  w.j  a  v  a  2 s  .c om*/

    testJsonConv(objectMapper, LOG, SemText.ofSentences(Locale.ITALIAN, "abcdefghilmno",
            ImmutableList.<Sentence>of(), ImmutableMap.of("a", MyMetadata.of())));

}

From source file:it.uniud.ailab.dcore.DistillerFactory.java

public static Distiller getDefaultCode() {
    Distiller d = new Distiller();

    // set the language detector tool
    d.setLanguageDetector(new CybozuLanguageDetectorAnnotator());

    // build the pipeline
    Pipeline p = new Pipeline();
    // split the text
    p.addStage(new OpenNlpBootstrapperAnnotator());
    // add wikipedia tags to tokens

    //annotate tokens with stemming
    p.addStage(new PorterStemmerAnnotator());
    // Uncomment the lines below to use the TagMe service
    // TagMeTokenAnnotator tagme = new TagMeTokenAnnotator();        
    // tagme.setApiKey("INSERT KEY HERE");        
    // p.addStage(tagme);
    // generate ngrams
    p.addStage(new SimpleNGramGeneratorAnnotator());

    // remove stopwords
    p.addStage(new StopwordSimpleFilterAnnotator());

    // annotate ngrams
    p.addStage(new StatisticalAnnotator());

    // Uncomment to use TagMe
    // p.addStage(new TagMeGramAnnotator());
    // Uncomment to use the emotional intensity annotator.
    // This way you'll see how different annotators lead to different
    // keyphrases detection
    // p.addStage(new SyuzhetAnnotator());
    // evaluate ngram features        
    LinearEvaluatorAnnotator evaluator = new LinearEvaluatorAnnotator();
    evaluator.addWeight(StatisticalAnnotator.DEPTH, 0.15);
    evaluator.addWeight(StatisticalAnnotator.HEIGHT, 0.25);
    evaluator.addWeight(StatisticalAnnotator.LIFESPAN, 0.1);
    evaluator.addWeight(StatisticalAnnotator.FREQUENCY_SENTENCE, 0.1);
    evaluator.addWeight(GenericNGramGeneratorAnnotator.NOUNVALUE, 0.3);
    evaluator.addWeight(GenericWikipediaAnnotator.WIKIFLAG, 0.1);

    p.addStage(evaluator);//from  w  w  w.  j  a v a2 s .com

    // Uncomment the line below to infer concepts.
    // Watch out: the inference process sends lots of requests to Wikipedia, 
    // so it significantly slows down the process
    // p.addStage(new WikipediaInferenceAnnotator());
    // filter results
    p.addStage(new SkylineGramFilterAnnotator());

    // remove redundant grams
    //p.addStage(new GramMergerAnnotator());
    p.addStage(new GramPrinter());
    p.addStage(new SentencePrinter());

    d.addPipeline(Locale.ENGLISH, p);
    d.addPipeline(Locale.ITALIAN, p);

    return d;
}

From source file:hk.idv.kenson.jrconsole.Console.java

/**
 * /*from   w  ww .j  a  v  a 2 s.  c  om*/
 * @param localeString
 * @return
 */
private static Locale getLocale(String localeString) {
    if ("default".equals(localeString))
        return Locale.getDefault();
    if ("canada".equals(localeString))
        return Locale.CANADA;
    if ("canada_french".equals(localeString))
        return Locale.CANADA_FRENCH;
    if ("china".equals(localeString))
        return Locale.CHINA;
    if ("chinese".equals(localeString))
        return Locale.CHINESE;
    if ("english".equals(localeString))
        return Locale.ENGLISH;
    if ("franch".equals(localeString))
        return Locale.FRANCE;
    if ("german".equals(localeString))
        return Locale.GERMAN;
    if ("germany".equals(localeString))
        return Locale.GERMANY;
    if ("italian".equals(localeString))
        return Locale.ITALIAN;
    if ("italy".equals(localeString))
        return Locale.ITALY;
    if ("japan".equals(localeString))
        return Locale.JAPAN;
    if ("japanese".equals(localeString))
        return Locale.JAPANESE;
    if ("korea".equals(localeString))
        return Locale.KOREA;
    if ("korean".equals(localeString))
        return Locale.KOREAN;
    if ("prc".equals(localeString))
        return Locale.PRC;
    if ("simplified_chinese".equals(localeString))
        return Locale.SIMPLIFIED_CHINESE;
    if ("taiwan".equals(localeString))
        return Locale.TAIWAN;
    if ("traditional_chinese".equals(localeString))
        return Locale.TRADITIONAL_CHINESE;
    if ("uk".equals(localeString))
        return Locale.UK;
    if ("us".equals(localeString))
        return Locale.US;

    String parts[] = localeString.split("_", -1);
    if (parts.length == 1)
        return new Locale(parts[0]);
    else if (parts.length == 2)
        return new Locale(parts[0], parts[1]);
    else
        return new Locale(parts[0], parts[1], parts[2]);
}

From source file:eu.trentorise.opendata.semtext.jackson.test.SemTextModuleTest.java

@Test
public void testMapper() throws IOException {

    SemTextModule.registerMetadata(Meaning.class, "a", Dict.class);
    SemTextModule.registerMetadata(Meaning.class, "b", Dict.class);
    SemTextModule.registerMetadata(Term.class, "c", Integer.class);
    SemTextModule.registerMetadata(Sentence.class, "a", MyMetadata.class);
    SemTextModule.registerMetadata(SemText.class, "a", Integer.class);

    objectMapper.registerModule(new SimpleModule() {
        {/*w  w w .  ja  v a2s. c  om*/
            setMixInAnnotation(MyMetadata.class, MyMetadataJackson.class);
        }
    });

    try {
        objectMapper.readValue("{\"start\":2, \"end\":1}", Term.class);
        Assert.fail("Should have failed because of missing attributes!");
    } catch (Exception ex) {

    }

    Meaning m1 = Meaning.of("a", MeaningKind.ENTITY, 0.2, Dict.of(Locale.ITALIAN, "a"),
            Dict.of(Locale.FRENCH, "b"), ImmutableMap.of("a", Dict.of("s")));
    Meaning m2 = Meaning.of("b", MeaningKind.ENTITY, 0.2, Dict.of(Locale.ITALIAN, "a"),
            Dict.of(Locale.FRENCH, "b"), ImmutableMap.of("b", Dict.of("s")));

    testJsonConv(objectMapper, LOG, Meaning.of("a", MeaningKind.CONCEPT, 0.2));

    Term term = Term.of(0, 2, MeaningStatus.SELECTED, m1, ImmutableList.of(m1, m2), ImmutableMap.of("c", 3));

    testJsonConv(objectMapper, LOG,
            SemText.ofSentences(Locale.ITALIAN, "abcdefghilmno", ImmutableList.of(
                    Sentence.of(0, 7, ImmutableList.of(term), ImmutableMap.of("a", MyMetadata.of("hello")))),
                    ImmutableMap.of("a", 9)));

}