Ignore:
Timestamp:
2015-07-24T19:43:34+02:00 (9 years ago)
Author:
nkaragiannakis
Message:

bugFix for files extraction

Location:
applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/extractor/LanguageDetector.java

    r31106 r31402  
    4343
    4444        if(!new File(languageProfilesPath).exists()){
    45             new File(languageProfilesPath).mkdir();
     45            //new File(languageProfilesPath).mkdir();
     46            new File(languageProfilesPath).mkdirs();
    4647        }
    47         File languageProfilesOutputFile1 = new File(languageProfilesPath + "/el");
     48        File languageProfilesOutputFile1 = new File(languageProfilesPath + "/el");       
    4849        File languageProfilesOutputFile2 = new File(languageProfilesPath +"/en");
     50       
     51        try {
     52            System.out.println("languageProfilesOutputFile1.exists: " + languageProfilesOutputFile1.exists());
     53            System.out.println("languageProfilesOutputFile1.getAbsolutePath(): " + languageProfilesOutputFile1.getAbsolutePath());
     54            System.out.println("languageProfilesOutputFile1.canRead(): " + languageProfilesOutputFile1.canRead());
     55            System.out.println("languageProfilesOutputFile1.canWrite(): " + languageProfilesOutputFile1.canWrite());
     56            //System.out.println("languageProfilesOutputFile1.canRead(): " + languageProfilesOutputFile1.);
     57           
     58            languageProfilesOutputFile1.createNewFile();
     59            languageProfilesOutputFile2.createNewFile();
     60        } catch (IOException ex) {
     61            Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
     62        }
     63       
    4964        //languageProfilesOutputFile.mkdirs();
    5065
     
    5772            Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
    5873        }
    59         System.out.println("deb1");
     74        //System.out.println("deb1");
    6075
    6176        FileOutputStream outputStream2 = null;
  • applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/extractor/TextualListLoader.java

    r31106 r31402  
    88import java.util.logging.Level;
    99import java.util.logging.Logger;
     10//import org.apache.log4j.Logger;
    1011
    1112/**
     
    1819public class TextualListLoader {
    1920   
    20     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TextualListLoader.class);
     21    //private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TextualListLoader.class);
     22    //private static final Logger LOG = Logger.getLogger(TextualListLoader.class);
    2123    private List<String> namesList;
    2224   
     
    3638                namesList.add(nextLine);
    3739            }
    38         LOG.info("Name occurences parsed successfully!");
     40        //LOG.info("Name occurences parsed successfully!");
    3941        }
    4042       
  • applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPluginHelper.java

    r31108 r31402  
    126126import org.openstreetmap.josm.plugins.core.TrainWorker;
    127127import org.openstreetmap.josm.plugins.extractor.LanguageDetector;
     128import org.openstreetmap.josm.plugins.extractor.SampleModelsExtractor;
    128129import org.openstreetmap.josm.plugins.features.ClassFeatures;
    129130import org.openstreetmap.josm.plugins.features.GeometryFeatures;
     
    159160    private static String MODEL_PATH;
    160161    private static String TEXTUAL_LIST_PATH;
    161 
     162    private static Map<String, List<String>> indirectClasses;
     163    private static Map<String, Integer> indirectClassesWithIDs;
     164    private static LanguageDetector languageDetector;
     165    private static String bestModelPath;
     166    private final String modelWithClassesPath;
     167   
     168   
    162169    // Selection that we are editing by using both dialogs
    163170    Collection<OsmPrimitive> sel;
     
    186193        }
    187194    };
     195
    188196   
    189     private static Map<String, List<String>> indirectClasses;
    190     private static Map<String, Integer> indirectClassesWithIDs;
    191     private static LanguageDetector languageDetector;
    192 
    193197    OSMRecPluginHelper(DefaultTableModel propertyData, Map<String, Map<String, Integer>> valueCount) {
    194198        this.tagData = propertyData;
     
    203207        MODEL_PATH = new File(MAIN_PATH).getParentFile() + "/OSMRec_models";
    204208        TEXTUAL_LIST_PATH = MODEL_PATH + "/textualList.txt";
     209        bestModelPath = MODEL_PATH + "/best_model";
     210        modelWithClassesPath = MODEL_PATH + "/model_with_classes";
    205211        languageDetector = LanguageDetector.getInstance(MODEL_PATH + "/profiles");
     212
     213        SampleModelsExtractor sa = new SampleModelsExtractor();
     214       
     215        sa.extractSampleSVMmodel("best_model", bestModelPath);
     216        sa.extractSampleSVMmodel("model_with_classes", modelWithClassesPath);
     217       
    206218    }
    207219
     
    14831495            configureContextsensitiveHelp("/Dialog/AddValue", true /* show help button */);
    14841496            final AddTagsDialog lala = this;
     1497
    14851498           
    14861499            loadOntology();
     
    14971510            }
    14981511           
    1499            
     1512            //if training process has not been performed, we use two sample SVM models, extracted from the jar
     1513            //File bestModelFile = new File(bestModelPath);
     1514            //File bestModelWithClassesFile = new File(modelWithClassesPath);
    15001515
    15011516            JPanel splitPanel = new JPanel(new BorderLayout(10,10));           
     
    16291644            //get a simple selection
    16301645            if(!osmPrimitiveSelection.isEmpty()){
    1631                 s = osmPrimitiveSelection.get(0);                       
    1632                 if(s.getInterestingTags().isEmpty()){
     1646                s = osmPrimitiveSelection.get(0);     
     1647                File modelDirectory = new File(MODEL_PATH);
     1648                String modelWithClassesPath = modelDirectory.getAbsolutePath() + "/model_with_classes";
     1649                File modelWithClassesFile = new File(modelWithClassesPath);
     1650                if(s.getInterestingTags().isEmpty() || !modelWithClassesFile.exists()){
    16331651                    loadSVMmodel(false);//load original model
    16341652                    createOSMObject(sel, false); //create object without class features
     
    16501668                public void valueChanged(ListSelectionEvent listSelectionEvent) {
    16511669                    if (!listSelectionEvent.getValueIsAdjusting()) {//This prevents double events
    1652                         System.out.println("tag selected: " + categoryList.getSelectedValue());
     1670                        //System.out.println("tag selected: " + categoryList.getSelectedValue());
    16531671                       
    16541672                        String selectedClass = categoryList.getSelectedValue();
     
    20942112
    20952113                        mapLabelsToIDs.put(modelSVMLabels[h], h);
    2096                         System.out.println(h + "   <->    " + modelSVMLabels[h]);
     2114                        //System.out.println(h + "   <->    " + modelSVMLabels[h]);
    20972115
    20982116                    }
     
    22112229                    }
    22122230                }
    2213                 System.out.println("final list:" + scoreMap);
     2231                //System.out.println("final list:" + scoreMap);
    22142232            }           
    22152233        }
  • applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/parsers/Mapper.java

    r31106 r31402  
    44import java.io.FileNotFoundException;
    55import java.io.InputStream;
     6import java.util.Collections;
    67import java.util.HashMap;
     8import java.util.LinkedHashMap;
    79import java.util.Map;
    810import java.util.Scanner;
     
    1719
    1820public class Mapper {
    19     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(Mapper.class);
     21    //private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(Mapper.class);
    2022    private final HashMap<String, String> mappings;
    2123    private final HashMap<String, Integer> mappingsWithIDs;
     
    2325    public Mapper(){   
    2426   
    25        mappings = new HashMap<>();
     27       mappings = new LinkedHashMap<>();
    2628       mappingsWithIDs = new HashMap<>();
    2729   
     
    4547        }
    4648        constructMappingsWithIDs();
    47          
    48     LOG.info("Mappings file parsed successfully!");     
     49        System.out.println("Mappings file parsed successfully!");
     50        //LOG.info("Mappings file parsed successfully!");     
    4951    }
    5052   
     
    5860   
    5961    public Map<String,Integer> getMappingsWithIDs(){
    60         return this.mappingsWithIDs;
     62        return Collections.unmodifiableMap(mappingsWithIDs);
    6163    }
    6264   
    6365    public Map<String,String> getMappings(){
    64         return this.mappings;
     66        return Collections.unmodifiableMap(mappings);
    6567    }       
    6668}
  • applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/parsers/Ontology.java

    r31106 r31402  
    5050        ontologyModel = ModelFactory.createOntologyModel();               
    5151       
    52         org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.ERROR);
     52        //org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.ERROR);
    5353        ontologyModel.read(owlFile, null);    //Hide RDFDefaultErrorHandler from terminal to keep clear output.
    54         org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO);
     54        //org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO);
    5555   
    5656        listHierarchy = ontologyModel.listHierarchyRootClasses().toList();
    5757        setListHierarchy(listHierarchy); 
    5858       
    59         ExtendedIterator classes = ontologyModel.listClasses();
     59        ExtendedIterator<OntClass> classes = ontologyModel.listClasses();
    6060        while (classes.hasNext()) {
    6161            String className;
    62             OntClass obj = (OntClass) classes.next();           
     62            OntClass obj = classes.next();           
    6363           
    6464            //compare localname with class name from map and call getSuperclass     
  • applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/parsers/TextualStatistics.java

    r31106 r31402  
    33import java.io.InputStream;
    44import java.util.ArrayList;
     5import java.util.Collections;
    56import java.util.List;
    67import java.util.Scanner;
     
    3031       
    3132        public List<String> getTextualList(){
    32             return textualList;
     33            return Collections.unmodifiableList(textualList);
    3334        }
    3435}
Note: See TracChangeset for help on using the changeset viewer.