codemining.util.serialization.Serializer Java Examples
The following examples show how to use
codemining.util.serialization.Serializer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerializableConversion.java From api-mining with GNU General Public License v3.0 | 5 votes |
/** * @param args * @throws SerializationException */ public static void main(String[] args) throws SerializationException { if (args.length < 2) { System.err .println("Usage <inputSerializedFIle> <outputSerializedFile>"); return; } final JavaSerialization javaSerializer = new JavaSerialization(); final Object javaObject = javaSerializer.deserializeFrom(args[0]); Serializer.getSerializer().serialize(javaObject, args[1]); }
Example #2
Source File: JavaVariableNameTypeDistribution.java From naturalize with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main(final String args[]) throws SerializationException { if (args.length != 2) { System.err.println("Usage <folderWithTypes> <SerialzedTypePrior>"); return; } final Collection<File> trainingFiles = FileUtils.listFiles(new File( args[0]), new RegexFileFilter(".*\\.java$"), DirectoryFileFilter.DIRECTORY); final JavaVariableNameTypeDistribution tp = JavaVariableNameTypeDistribution .buildFromFiles(trainingFiles); Serializer.getSerializer().serialize(tp, args[1]); }
Example #3
Source File: InterpolatedIdentifierRenamings.java From naturalize with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Load as a static variable the global model. * * @param globalNgramDirectory * @throws SerializationException */ private synchronized void loadNGramModel(final String globalNgramDirectory) throws SerializationException { if (ngramModelPath != null && !ngramModelPath.equals(globalNgramDirectory)) { throw new IllegalArgumentException("Two global models..."); } if (globalNgram != null) { return; } globalNgram = (AbstractNGramLM) Serializer.getSerializer() .deserializeFrom(globalNgramDirectory); ngramModelPath = globalNgramDirectory; }
Example #4
Source File: CodeUtils.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Save folds or tokens to file using Kryo serializer * * @author Jaroslav Fowkes */ public static <K, V> void saveFolds(final HashMap<K, V> folds, final String path) { try { Serializer.getSerializer().serialize(folds, path); System.out.printf("Folds saved in " + path); } catch (final SerializationException e) { e.printStackTrace(); } }
Example #5
Source File: GibbsSampler.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Serialize the present sampler state */ public void saveSelf(final String path) { try { Serializer.getSerializer().serialize(this, path); System.out.printf("Gibbs sampler state saved in " + path); } catch (final SerializationException e) { e.printStackTrace(); } }
Example #6
Source File: GibbsSampler.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Read in and return serialized sampler */ public static GibbsSampler readCorpus(final String serPath) { GibbsSampler sampler = null; try { sampler = (GibbsSampler) Serializer.getSerializer() .deserializeFrom(serPath); } catch (final SerializationException e) { e.printStackTrace(); } return sampler; }
Example #7
Source File: SerializableConversion.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param args * @throws SerializationException */ public static void main(String[] args) throws SerializationException { if (args.length < 2) { System.err .println("Usage <inputSerializedFIle> <outputSerializedFile>"); return; } final JavaSerialization javaSerializer = new JavaSerialization(); final Object javaObject = javaSerializer.deserializeFrom(args[0]); Serializer.getSerializer().serialize(javaObject, args[1]); }
Example #8
Source File: NamingEvaluator.java From naturalize with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @param args * @throws IOException * @throws ClassNotFoundException * @throws SerializationException * @throws NoSuchMethodException * @throws InvocationTargetException * @throws IllegalAccessException * @throws InstantiationException * @throws SecurityException * @throws IllegalArgumentException */ public static void main(final String[] args) throws IOException, SerializationException, IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { if (args.length != 4) { System.err .println("Usage <lmModel> <folder> variable|method <renamerClass> [renamerArgument]"); return; } final File directory = new File(args[1]); LOGGER.info("Reading LM..."); final AbstractNGramLM langModel = ((AbstractNGramLM) Serializer .getSerializer().deserializeFrom(args[0])); final ResultObject[] data = new ResultObject[ScopeType.values().length]; for (int i = 0; i < data.length; i++) { data[i] = new ResultObject(); } final AbstractIdentifierRenamings renamer; if (args.length == 4) { renamer = (AbstractIdentifierRenamings) Class.forName(args[3]) .getDeclaredConstructor(AbstractNGramLM.class) .newInstance(langModel); } else { renamer = (AbstractIdentifierRenamings) Class .forName(args[3]) .getDeclaredConstructor(AbstractNGramLM.class, String.class) .newInstance(langModel, args[4]); } final NamingEvaluator ve = new NamingEvaluator(renamer, data); final IScopeExtractor scopeExtractor = ScopesTUI .getScopeExtractorByName(args[2]); ve.performEvaluation( FileUtils.listFiles(directory, langModel.getTokenizer() .getFileFilter(), DirectoryFileFilter.DIRECTORY), scopeExtractor); }
Example #9
Source File: IdentifierNGramModelBuilder.java From naturalize with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @param args * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException * @throws IOException * @throws SecurityException * @throws NoSuchMethodException * @throws InvocationTargetException * @throws IllegalArgumentException * @throws SerializationException */ public static void main(final String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, SerializationException { final CommandLineParser parser = new PosixParser(); final Options options = new Options(); options.addOption(OptionBuilder.isRequired(true) .withDescription("n-gram n parameter. The size of n.").hasArg() .create("n")); options.addOption(OptionBuilder .isRequired(true) .withLongOpt("trainDir") .hasArg() .withDescription("The directory containing the training files.") .create("t")); options.addOption(OptionBuilder.isRequired(true).withLongOpt("output") .hasArg() .withDescription("File to output the serialized n-gram model.") .create("o")); final CommandLine parse; try { parse = parser.parse(options, args); } catch (ParseException ex) { System.err.println(ex.getMessage()); final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("buildlm", options); return; } final ITokenizer tokenizer = new JavaTokenizer(); final String nStr = parse.getOptionValue("n"); final int n = Integer.parseInt(nStr); final File trainDirectory = new File(parse.getOptionValue("t")); checkArgument(trainDirectory.isDirectory()); final String targetSerFile = parse.getOptionValue("o"); final IdentifierNeighborsNGramLM dict = new IdentifierNeighborsNGramLM( n, tokenizer); LOGGER.info("NGramLM Model builder started with " + n + "-gram for files in " + trainDirectory.getAbsolutePath()); final Collection<File> files = FileUtils.listFiles(trainDirectory, dict.modelledFilesFilter(), DirectoryFileFilter.DIRECTORY); dict.trainModel(files); LOGGER.info("Ngram model build. Adding Smoother..."); final AbstractNGramLM ng = new StupidBackoff(dict); LOGGER.info("Ngram model build. Serializing..."); Serializer.getSerializer().serialize(ng, targetSerFile); }