-
-
Save gastaldi/7249211 to your computer and use it in GitHub Desktop.
| /** | |
| * Copyright 2013 Red Hat, Inc. and/or its affiliates. | |
| * | |
| * Licensed under the Eclipse Public License version 1.0, available at | |
| * http://www.eclipse.org/legal/epl-v10.html | |
| */ | |
| package org.jboss.forge.addon.javaee; | |
| import org.jboss.forge.addon.facets.Facet; | |
| import org.jboss.forge.furnace.util.Predicate; | |
| /** | |
| * Registers constraints for a specific facet | |
| * | |
| * @author <a href="ggastald@redhat.com">George Gastaldi</a> | |
| */ | |
| public interface FacetFilterRegistry | |
| { | |
| public <T extends Facet<?>> void register(Class<T> facetType, Predicate<T> filter); | |
| } |
| /** | |
| * Copyright 2013 Red Hat, Inc. and/or its affiliates. | |
| * | |
| * Licensed under the Eclipse Public License version 1.0, available at | |
| * http://www.eclipse.org/legal/epl-v10.html | |
| */ | |
| package org.jboss.forge.addon.javaee; | |
| import java.util.Collection; | |
| import java.util.HashMap; | |
| import java.util.LinkedList; | |
| import java.util.Map; | |
| import javax.enterprise.inject.spi.InjectionPoint; | |
| import org.jboss.forge.addon.facets.Facet; | |
| import org.jboss.forge.addon.ui.cdi.CommandScoped; | |
| import org.jboss.forge.addon.ui.input.InputComponent; | |
| import org.jboss.forge.addon.ui.input.InputComponentInjectionEnricher; | |
| import org.jboss.forge.addon.ui.input.SelectComponent; | |
| import org.jboss.forge.furnace.util.Assert; | |
| import org.jboss.forge.furnace.util.Predicate; | |
| /** | |
| * Implementation of the {@link FacetFilterRegistry} interface | |
| * | |
| * @author <a href="ggastald@redhat.com">George Gastaldi</a> | |
| */ | |
| @CommandScoped | |
| @SuppressWarnings("unchecked") | |
| public class FacetFilterRegistryImpl implements InputComponentInjectionEnricher, FacetFilterRegistry | |
| { | |
| private Map<String, Predicate<Object>> filters = new HashMap<String, Predicate<Object>>(); | |
| @Override | |
| public <T extends Facet<?>> void register(Class<T> facetType, Predicate<T> filter) | |
| { | |
| Assert.notNull(facetType, "Facet type may not be null"); | |
| Assert.notNull(filter, "Filter may not be null"); | |
| String key = facetType.getName(); | |
| filters.put(key, (Predicate<Object>) filter); | |
| } | |
| @Override | |
| public void enrich(InjectionPoint injectionPoint, InputComponent<?, ?> input) | |
| { | |
| // Works only for SelectComponents | |
| if (input instanceof SelectComponent && Facet.class.isAssignableFrom(input.getValueType())) | |
| { | |
| SelectComponent<?, Object> select = (SelectComponent<?, Object>) input; | |
| String key = input.getValueType().getName(); | |
| Predicate<Object> filter = filters.get(key); | |
| if (filter != null) | |
| { | |
| Collection<Object> filteredFacets = new LinkedList<Object>(); | |
| Iterable<Object> valueChoices = select.getValueChoices(); | |
| if (valueChoices != null) | |
| { | |
| for (Object choice : valueChoices) | |
| { | |
| if (filter.accept(choice)) | |
| { | |
| filteredFacets.add(choice); | |
| } | |
| } | |
| } | |
| select.setValueChoices(filteredFacets); | |
| } | |
| } | |
| } | |
| } |
What is done till now is
package stensuffix;
import java.util.Scanner;
public class NewClass {
public static void main(String args[])
{
Scanner sh = new Scanner(System.in);
System.out.println("Enter a word");
String str = sh.next();
char[] ch = str.toCharArray();
int y = str.length();
for (int m = y ; m <= y; m--)
{
String pl1 = new String(ch,0,m);
if(pl1.length()>=2)
{
int l=8;
char[] dh = new char[l];
int c=y-1;
int g = l-1;
for (int j=c; j<=y; j--)
{
if(m>2)
{
dh[g]= ch[j];
String pl = new String(ch,0,--m);
String mpm = new String(dh,0,8);
System.out.println("Stem/Suffix:"+pl +"/"+mpm);
--g;
}
}
}
}
}
}
but this prints spaces in suffix which is not required
I wan in form like.
abstract
abstrac/t
abstra/ct
abstr/act
abst/ract
abs/tract
ab/stract
How ever i could reach with output as
word description
Stem/Suffix: descriptio/n
Stem/Suffix: descripti/no
Stem/Suffix: descript/noi
Stem/Suffix: descrip/noit ................
suffix should come in reverse of what its showing.. with below code
import java.util.Collections;
import java.util.Scanner;
public class MorphemeA
{
public static void main(String args[])
{
Scanner sh = new Scanner(System.in);
System.out.println("Enter a word");
String str = sh.next();
char[] ch = str.toCharArray();
int y = str.length();
for (int m = y ; m <= y; m--)
{
String pl1 = new String(ch,0,m);
if(pl1.length()>=2)
{
int l=8;
char[] dh = new char[l];
int c=y-1;
int g = l-1;
char[] eh = new char[l];
int h = 0;
for (int j=c; j<=y; j--)
{
if(m>2)
{
eh[h] = ch[j];
// Collections.reverse(dh);
String pl = new String(ch,0,--m);
//Collections.reverse(eh);
String mpm = new String(eh,0,8);
System.out.println("Stem/Suffix:"+pl +"/"+mpm);
h++;
}
}
}
}
}
}
Get me some idea over below requirements: code is most wellcome..........!!!!!!!!!!
MODULE 1:Morphological segmentation
DIAGRAM
ALGORITHM:
Input: Read the Lexicon L /Corpus C
(i) In case of corpus C create a unique word list (since it is learns both inflectional and derivational morphology)
(ii)For Lexicon L is based on a collection of words in derivational morphology
Morpheme identification:
The following procedure demonstrates the generation of all probable stems and suffixes
(i) Decomposition of the given word (w) into possible suffixes and stems using the p-similar technique.
(ii) The maximum length of suffix length is taken as 8.
(iii) The minimum stem length is taken as 2.
Examples:
Stemlist Suffixlist
Sleeping
Sleepin g
Sleepi ng
Sleep ing
Slee ping
Sle eping
Sl eeping
Input: Lexicon L
Output: Candidate stem-suffix pair list
Algorithm:
For each input word a ∈ L
where b, c, d ∈ L such that ∃ x1,x2,x3
find a=x1s1, b=x1s2,c=x2s1,d=x2s2
add x1 to set of stems S_ stems
add s1 to set of suffixes S_ suffixes
End For
Generation of stems and suffixes
The following procedure is followed to identify the invalid stems and suffixes due to over stemming.
Input: Candidate stem-suffix pair list
Output: Valid Stems and suffixes
Algorithm:
Given each word a∈ L such that ∃ suffix si and stem xi
For each suffix s1 from suffix list,
If asi ∈ S_ suffixes
b2a=b1 and b1, b2∈ S_ stems
then Replace b1 by b2 and s1 by as1
End if
End for
Generation of paradigms
The following procedure generates a paradigm which contains suffixes for the list of stems for the given input.
Input: Valid stems-suffix list
Output: Generation of paradigms
Algorithm:
For the generated stem(x)
do
if (x) is not in the (S-stems) add (x) into (S-stems)
if (x) is in the (S-stems)
then if corresponding (S) is not in the (S_suffixes) of a particular stem (x) add (S) into the (S_suffixes) of a particular stem (x)
next.
End if
End For