Как обучить модель итальянского языка в OpenNLP на Hadoop?

Я хотел бы реализовать алгоритм обработки естественного языка на Hadoop для итальянского языка.

У меня есть 2 вопроса;

  1. как я могу найти алгоритм поиска корней для итальянского языка?
  2. как интегрироваться в hadoop?

вот мой код

String pathSent=...tagged sentences...;
String pathChunk=....chunked train path....;
File fileSent=new File(pathSent);
File fileChunk=new File(pathChunk);
InputStream inSent=null;
InputStream inChunk=null;

inSent = new FileInputStream(fileSent);
inChunk = new FileInputStream(fileChunk);
POSModel posModel=POSTaggerME.train("it", new WordTagSampleStream((
new InputStreamReader(inSent))), ModelType.MAXENT, null, null, 3, 3);

ObjectStream stringStream =new PlainTextByLineStream(new InputStreamReader(inChunk));
ObjectStream chunkStream = new ChunkSampleStream(stringStream);
ChunkerModel chunkModel=ChunkerME.train("it",chunkStream ,1, 1);
this.tagger= new POSTaggerME(posModel);
this.chunker=new ChunkerME(chunkModel);


inSent.close();
inChunk.close();

person giusy    schedule 29.05.2015    source источник


Ответы (1)


Вам нужен грамматический движок предложений:

"io voglio andare a casa"

io, sostantivo
volere, verbo
andare, verbo
a, preposizione semplice
casa, oggetto

когда у вас есть помеченное предложение, вы можете преподавать OpenNLP.

В Hadoop создайте собственную карту

 public class Map extends Mapper<longwritable,
                            intwritable="" text,=""> {  

           private final static IntWritable one =
                           new IntWritable(1);  
          private Text word = new Text();    

          @Override  public void map(LongWritable key, Text value,
                      Context context)
      throws IOException, InterruptedException {

            //your code here
       } 
  }

В Hadoop создайте собственное сокращение

public class Reduce extends Reducer<text,
              intwritable,="" intwritable="" text,=""> {
 @Override
 protected void reduce(
   Text key,
   java.lang.Iterable<intwritable> values,
   org.apache.hadoop.mapreduce.Reducer<text,
           intwritable,="" intwritable="" text,="">.Context context)
   throws IOException, InterruptedException {
       // your reduce here
 }
}

настроить оба

public static void main(String[] args)
                      throws Exception {
  Configuration conf = new Configuration();

  Job job = new Job(conf, "opennlp");
  job.setJarByClass(CustomOpenNLP.class);

  job.setOutputKeyClass(Text.class);
  job.setOutputValueClass(IntWritable.class);

  job.setMapperClass(Map.class);
  job.setReducerClass(Reduce.class);

  job.setInputFormatClass(TextInputFormat.class);
  job.setOutputFormatClass(TextOutputFormat.class);

  FileInputFormat.addInputPath(job, new Path(args[0]));
  FileOutputFormat.setOutputPath(job, new Path(args[1]));

  job.waitForCompletion(true);
}
person venergiac    schedule 22.06.2015