Tabnine Logo
FrequencyDistribution
Code IndexAdd Tabnine to your IDE (free)

How to use
FrequencyDistribution
in
de.tudarmstadt.ukp.dkpro.teaching.core

Best Java code snippets using de.tudarmstadt.ukp.dkpro.teaching.core.FrequencyDistribution (Showing top 9 results out of 315)

origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

public void addSamples(C t, Iterable<V> samples) {
  FrequencyDistribution<V> freqDist = null;
  if (cfd.containsKey(t)) {
    freqDist = cfd.get(t);
  }
  else {
    freqDist = new FrequencyDistribution<V>();
    cfd.put(t, freqDist);
  }
  long countBefore = freqDist.getN();
  freqDist.incAll(samples);
  this.n = n + (freqDist.getN() - countBefore); 
}
 
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

public FrequencyDistribution(Iterable<T> iterable) {
  this();
  for (T o : iterable) {
    addSample(o, 1);
  }
}
 
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

  @Test
  public void cfdTest() {
    
    List<String> tokens = Arrays.asList("This is a first test that contains a first test example".split(" "));
    
    FrequencyDistribution<String> fd = new FrequencyDistribution<String>();
    fd.incAll(tokens);
    
    System.out.println(fd);
    
    assertEquals(11, fd.getN());
    assertEquals(8, fd.getB());
    
    assertEquals(0, fd.getCount("humpelgrumpf"));
    assertEquals(1, fd.getCount("This"));
    assertEquals(2, fd.getCount("test"));
  }
}
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

  public static void main(String[] args) {
    
    List<String> tokens = Arrays.asList(StringUtils.split("This is a simple example sentence containing an example ."));
    FrequencyDistribution<String> fq = new FrequencyDistribution<String>(tokens);
    
    System.out.println(fq.getCount("example"));
    System.out.println(fq.getCount("is"));
  }
}
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.frequency

  @Override
  public long getNrOfTokens()
    throws Exception
  {
    return cfd.getFrequencyDistribution(1).getN();
  }
}
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

public long getCount(C t, V u) {
  if (cfd.containsKey(t)) {
    return cfd.get(t).getCount(u);
  }
  else {
    return 0;
  }
}
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

  @Override
  public String toString()
  {
    StringBuilder sb = new StringBuilder();
    for (C t : cfd.keySet()) {
      sb.append(t.toString());
      sb.append(System.getProperty("line.separator"));
      sb.append(cfd.get(t).toString());
      sb.append(System.getProperty("line.separator"));
    }

    return sb.toString();
  }
}
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

public void incAll(Iterable<T> iterable ) {
  for (T o : iterable) {
    addSample(o, 1);
  }    
}
 
origin: de.tudarmstadt.ukp.dkpro.teaching/de.tudarmstadt.ukp.dkpro.teaching.core

public void inc(T o) {
  addSample(o, 1);
}
 
de.tudarmstadt.ukp.dkpro.teaching.coreFrequencyDistribution

Javadoc

Inspired by nltk.probability.FreqDist

Most used methods

  • getN
  • <init>
  • getCount
  • incAll
  • addSample
  • getB
  • toString

Popular in Java

  • Making http requests using okhttp
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onRequestPermissionsResult (Fragment)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now