Exemple #1
0
 public CreatePatternsThread(CreatePatterns <E> _enclosing, IDictionary <string, DataInstance> sents, IList <string> sentIds, Properties props, ConstantsAndVariables.PatternForEachTokenWay storePatsForEachToken)
 {
     this._enclosing = _enclosing;
     //return patternsForEachToken;
     //  /**
     //   * Returns null if using DB backed!!
     //   * @return
     //   */
     //  public Map<String, Map<Integer, Set<Integer>>> getPatternsForEachToken() {
     //    return patternsForEachToken;
     //  }
     //String label;
     // Class otherClass;
     //this.label = label;
     // this.otherClass = otherClass;
     this.sents       = sents;
     this.sentIds     = sentIds;
     this.patsForEach = PatternsForEachToken.GetPatternsInstance(props, storePatsForEachToken);
 }
Exemple #2
0
        public static PatternsForEachToken GetPatternsInstance(Properties props, ConstantsAndVariables.PatternForEachTokenWay storePatsForEachToken)
        {
            storeWay = storePatsForEachToken;
            PatternsForEachToken p = null;

            switch (storePatsForEachToken)
            {
            case ConstantsAndVariables.PatternForEachTokenWay.Memory:
            {
                p = new PatternsForEachTokenInMemory(props);
                break;
            }

            case ConstantsAndVariables.PatternForEachTokenWay.Db:
            {
                p = new PatternsForEachTokenDB(props);
                break;
            }

            case ConstantsAndVariables.PatternForEachTokenWay.Lucene:
            {
                try
                {
                    Type c = Sharpen.Runtime.GetType("edu.stanford.nlp.patterns.surface.PatternsForEachTokenLucene");
                    p = (PatternsForEachToken)c.GetDeclaredConstructor(typeof(Properties)).NewInstance(props);
                    break;
                }
                catch (TypeLoadException)
                {
                    throw new Exception("Lucene option is not distributed (license clash). Email us if you really want it.");
                }
                catch (ReflectiveOperationException e)
                {
                    throw new Exception(e);
                }
                break;
            }
            }
            return(p);
        }