Exemplo n.º 1
0
 public static IDictionary <int, ISet> GetPatternsAroundTokens(PatternFactory.PatternType patternType, DataInstance sent, ICollection <CandidatePhrase> stopWords)
 {
     if (patternType.Equals(PatternFactory.PatternType.Surface))
     {
         return(SurfacePatternFactory.GetPatternsAroundTokens(sent, stopWords));
     }
     else
     {
         if (patternType.Equals(PatternFactory.PatternType.Dep))
         {
             return((IDictionary)DepPatternFactory.GetPatternsAroundTokens(sent, stopWords));
         }
         else
         {
             throw new NotSupportedException();
         }
     }
 }
Exemplo n.º 2
0
 public static bool Subsumes(PatternFactory.PatternType patternClass, Edu.Stanford.Nlp.Patterns.Pattern pat, Edu.Stanford.Nlp.Patterns.Pattern p)
 {
     if (patternClass.Equals(PatternFactory.PatternType.Surface))
     {
         return(SurfacePattern.Subsumes((SurfacePattern)pat, (SurfacePattern)p));
     }
     else
     {
         if (patternClass.Equals(PatternFactory.PatternType.Dep))
         {
             return(DepPattern.Subsumes((DepPattern)pat, (DepPattern)p));
         }
         else
         {
             throw new NotSupportedException();
         }
     }
 }
Exemplo n.º 3
0
 public override string ToString()
 {
     if (type.Equals(PatternFactory.PatternType.Surface))
     {
         return(ToStringSurface());
     }
     else
     {
         if (type.Equals(PatternFactory.PatternType.Dep))
         {
             return(ToStringDep());
         }
         else
         {
             throw new NotSupportedException();
         }
     }
 }
Exemplo n.º 4
0
 public static DataInstance GetNewInstance(PatternFactory.PatternType type, ICoreMap s)
 {
     if (type.Equals(PatternFactory.PatternType.Surface))
     {
         return(new DataInstanceSurface(s.Get(typeof(CoreAnnotations.TokensAnnotation))));
     }
     else
     {
         if (type.Equals(PatternFactory.PatternType.Dep))
         {
             return(new DataInstanceDep(s));
         }
         else
         {
             throw new NotSupportedException();
         }
     }
 }
Exemplo n.º 5
0
 public static void SetUp(Properties props, PatternFactory.PatternType patternType, ICollection <string> labels)
 {
     ArgumentParser.FillOptions(typeof(PatternFactory), props);
     numWordsCompoundMax = 0;
     if (numWordsCompound.Contains(",") || numWordsCompound.Contains(";"))
     {
         string[] toks = numWordsCompound.Split(";");
         foreach (string t in toks)
         {
             string[] toks2    = t.Split(",");
             int      numWords = System.Convert.ToInt32(toks2[1]);
             numWordsCompoundMapped[toks2[0]] = numWords;
             if (numWords > numWordsCompoundMax)
             {
                 numWordsCompoundMax = numWords;
             }
         }
     }
     else
     {
         numWordsCompoundMax = System.Convert.ToInt32(numWordsCompound);
         foreach (string label in labels)
         {
             numWordsCompoundMapped[label] = System.Convert.ToInt32(numWordsCompound);
         }
     }
     if (patternType.Equals(PatternFactory.PatternType.Surface))
     {
         SurfacePatternFactory.SetUp(props);
     }
     else
     {
         if (patternType.Equals(PatternFactory.PatternType.Dep))
         {
             DepPatternFactory.SetUp(props);
         }
         else
         {
             throw new NotSupportedException();
         }
     }
 }
Exemplo n.º 6
0
 /// <summary>Get set of patterns around this token.</summary>
 public static ISet GetContext(PatternFactory.PatternType patternClass, DataInstance sent, int i, ICollection <CandidatePhrase> stopWords)
 {
     if (patternClass.Equals(PatternFactory.PatternType.Surface))
     {
         return(SurfacePatternFactory.GetContext(sent.GetTokens(), i, stopWords));
     }
     else
     {
         return(DepPatternFactory.GetContext(sent, i, stopWords));
     }
 }