예제 #1
0
        public string GetPathSetting(string namePath, string defaultVal)
        {
            string retP = SettingPath0(namePath, defaultVal);

            if (retP == null)
            {
                return(defaultVal);
            }
            string ret  = HostSystem.ToRelativePath(retP, RuntimeDirectory);
            string retA = HostSystem.GetAbsolutePath(retP);

            return(ret);
        }
예제 #2
0
        internal long LoadFileByLines0(string filename, WordExpander expandWithWordNet)
        {
            checkDbLock();
            long   totals = 0;
            string line;
            long   linecount = 0;

            if (HostSystem.FileExists(filename))
            {
                string absoluteFileName                   = HostSystem.GetAbsolutePath(filename);
                System.IO.TextReader       tr             = new StreamReader(absoluteFileName);
                Dictionary <ulong, string> contentIdPairs = new Dictionary <ulong, string>();

                while ((linecount < 80000) && ((line = tr.ReadLine()) != null))
                {
                    linecount++;
                    if (linecount % 1000 == 0)
                    {
                        // batch a 1000
                        writeToLog("Lucene learn {0}", linecount);
                        int numIndexedb = Index(contentIdPairs, expandWithWordNet);
                        writeToLog("Indexed {0} lines.", numIndexedb);
                        totals += linecount;

                        contentIdPairs = new Dictionary <ulong, string>();
                    }
                    line = line.Trim();
                    if (line.Length != 0 && line[0] != '#')
                    {
                        contentIdPairs.Add(IncDocId(), line);
                    }
                }
                tr.Close();
                // Indexing:
                int numIndexed = Index(contentIdPairs, expandWithWordNet);
                writeToLog("Indexed {0} lines.", numIndexed);


                writeToLog("Last Line Mlearn {0}", linecount);
            }
            else
            {
                writeToLog(" LoadFileByLines cannot find file '{0}'", filename);
            }
            return(totals);
        }