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

How to use
Quantity
in
uk.gov.dstl.baleen.types.common

Best Java code snippets using uk.gov.dstl.baleen.types.common.Quantity (Showing top 18 results out of 315)

origin: dstl/baleen

public static Quantity createWeightQuantity(
  JCas jCas,
  int begin,
  int end,
  String value,
  double quantity,
  String unit,
  double normalizedQuantity) {
 Quantity q = new Quantity(jCas);
 q.setBegin(begin);
 q.setEnd(end);
 q.setConfidence(1.0);
 q.setValue(value);
 q.setQuantity(quantity);
 q.setUnit(unit);
 q.setNormalizedQuantity(normalizedQuantity);
 q.setNormalizedUnit("kg");
 q.setSubType(WEIGHT);
 q.addToIndexes();
 return q;
}
origin: uk.gov.dstl.baleen/baleen-uima

/**
 * @generated
 * @param jcas JCas to which this Feature Structure belongs
 * @param begin offset to the begin spot in the SofA
 * @param end offset to the end spot in the SofA
 */
public Quantity(JCas jcas, int begin, int end) {
 super(jcas);
 setBegin(begin);
 setEnd(end);
 readObject();
}
origin: dstl/baleen

@Test
public void test() throws UIMAException {
 jCas.setDocumentText("The weapons were found 50 miles south-west of London");
 Quantity q = new Quantity(jCas);
 q.setBegin(23);
 q.setEnd(31);
 q.setSubType("distance");
 q.addToIndexes();
 Location l = new Location(jCas, 46, 52);
 l.addToIndexes();
 processJCas();
 assertEquals("50 miles south-west of London", l.getCoveredText());
 assertEquals(1, JCasUtil.select(jCas, Quantity.class).size());
}
origin: dstl/baleen

public static void checkQuantityProperties(
  Quantity q,
  int begin,
  int end,
  String value,
  Double quantity,
  Double normQuantity,
  String unit,
  String normUnit) {
 // String positions/content
 assertEquals(begin, q.getBegin());
 assertEquals(end, q.getEnd());
 assertEquals(value, q.getValue());
 // Quantities
 assertEquals(quantity, Double.valueOf(q.getQuantity()));
 assertEquals(normQuantity, Double.valueOf(q.getNormalizedQuantity()));
 // units
 assertEquals(unit, q.getUnit());
 assertEquals(normUnit, q.getNormalizedUnit());
}
origin: dstl/baleen

@Test
public void testSingleType() throws Exception {
 jCas.setDocumentText(
   "The package weighed 4st 7oz. There was an additional 3lbs found lying near by.");
 Annotations.createWeightQuantity(jCas, 20, 23, "4st", 4, "st", 25.4012);
 Annotations.createWeightQuantity(jCas, 24, 27, "7oz", 7, "oz", 0.198447);
 Quantity q3 = Annotations.createWeightQuantity(jCas, 53, 57, "3lbs", 3, "lb", 1.36078);
 processJCas();
 assertEquals(2, JCasUtil.select(jCas, Quantity.class).size());
 Quantity q = JCasUtil.selectByIndex(jCas, Quantity.class, 0);
 assertEquals("4st 7oz", q.getCoveredText());
 assertEquals("4st 7oz", q.getValue());
 assertNull(q.getUnit());
 assertEquals(0.0, q.getQuantity(), 0.0);
 assertEquals("kg", q.getNormalizedUnit());
 assertEquals(25.599647, q.getNormalizedQuantity(), 0.0);
 assertEquals("weight", q.getSubType());
 assertEquals(q3, JCasUtil.selectByIndex(jCas, Quantity.class, 1));
}
origin: dstl/baleen

 @Test
 public void testQuantityPeopleKeepOriginal() throws Exception {
  jCas.setDocumentText("47,000 people voted in an independence referendum");

  Quantity n = new Quantity(jCas, 0, 6);
  n.addToIndexes();

  processJCas(People.PARAM_REMOVE_ORIGINAL, false);

  assertEquals(1, JCasUtil.select(jCas, Quantity.class).size());
  assertEquals("47,000", JCasUtil.selectByIndex(jCas, Quantity.class, 0).getCoveredText());
  assertEquals(1, JCasUtil.select(jCas, Organisation.class).size());
  assertEquals(
    "47,000 people", JCasUtil.selectByIndex(jCas, Organisation.class, 0).getCoveredText());
 }
}
origin: dstl/baleen

@Test
public void testQuantityPeople() throws Exception {
 jCas.setDocumentText("47,000 people voted in an independence referendum");
 Quantity n = new Quantity(jCas, 0, 6);
 n.addToIndexes();
 processJCas();
 assertEquals(0, JCasUtil.select(jCas, Quantity.class).size());
 assertEquals(1, JCasUtil.select(jCas, Organisation.class).size());
 assertEquals(
   "47,000 people", JCasUtil.selectByIndex(jCas, Organisation.class, 0).getCoveredText());
}
origin: dstl/baleen

 @Override
 public void validate(Quantity t) {
  super.validate(t);

  assertEquals(quantity, t.getQuantity(), 0.0);
  assertEquals(normalizedQuantity, t.getNormalizedQuantity(), 0.00001);
  assertEquals(unit, t.getUnit());
  assertEquals(normalizedUnit, t.getNormalizedUnit());
  assertEquals(quantityType, t.getSubType());
 }
}
origin: dstl/baleen

 return Optional.of(new Person(jCas));
case "Quantity":
 return Optional.of(new Quantity(jCas));
case "Temporal":
 return Optional.of(new Temporal(jCas));
origin: dstl/baleen

@Test
public void testRemoveQuantity() throws UIMAException {
 jCas.setDocumentText("The weapons were found 20 miles north of London");
 Quantity q = new Quantity(jCas);
 q.setBegin(23);
 q.setEnd(31);
 q.setSubType("distance");
 q.addToIndexes();
 Location l = new Location(jCas, 41, 47);
 l.addToIndexes();
 processJCas(ExpandLocationToDescription.PARAM_REMOVE_QUANTITY, true);
 assertEquals("20 miles north of London", l.getCoveredText());
 assertEquals(0, JCasUtil.select(jCas, Quantity.class).size());
}
origin: dstl/baleen

/**
 * @generated
 * @param jcas JCas to which this Feature Structure belongs
 * @param begin offset to the begin spot in the SofA
 * @param end offset to the end spot in the SofA
 */
public Quantity(JCas jcas, int begin, int end) {
 super(jcas);
 setBegin(begin);
 setEnd(end);
 readObject();
}
origin: dstl/baleen

d3.addToIndexes();
Quantity q1 = new Quantity(jCas, 153, 156);
q1.addToIndexes();
Quantity q2 = new Quantity(jCas, 167, 170);
q2.addToIndexes();
origin: uk.gov.dstl.baleen/baleen-collectionreaders

 return Optional.of(new Person(jCas));
case "Quantity":
 return Optional.of(new Quantity(jCas));
case "Temporal":
 return Optional.of(new Temporal(jCas));
origin: dstl/baleen

public static Quantity createDistanceQuantity(
  JCas jCas,
  int begin,
  int end,
  String value,
  int quantity,
  String unit,
  double normalizedQuantity) {
 Quantity q = new Quantity(jCas);
 q.setBegin(begin);
 q.setEnd(end);
 q.setConfidence(1.0);
 q.setValue(value);
 q.setQuantity(quantity);
 q.setUnit(unit);
 q.setNormalizedQuantity(normalizedQuantity);
 q.setNormalizedUnit("m");
 q.setSubType("length");
 q.addToIndexes();
 return q;
}
origin: dstl/baleen

@Test
public void testUnmarked() throws UIMAException {
 Quantity q = new Quantity(jCas);
 q.setBegin(18);
 q.setEnd(21);
 q.addToIndexes();
 processJCas();
 assertAnnotations(2, Entity.class, new TestEntity<>(1, "blue powder"));
 assertEquals(1, JCasUtil.select(jCas, Relation.class).size());
 Relation r = JCasUtil.selectByIndex(jCas, Relation.class, 0);
 assertEquals(18, r.getBegin());
 assertEquals(q, r.getSource());
 assertEquals(36, r.getEnd());
 assertNotNull(r.getTarget());
 assertEquals("QUANTITY", r.getRelationshipType());
}
origin: dstl/baleen

 @Override
 public void map(JCas jCas, Element element, AnnotationCollector collector) {
  switch (element.tagName().toLowerCase()) {
   case "time":
    collector.add(new Temporal(jCas));
    break;
   case "meter":
    collector.add(new Quantity(jCas));
    break;
   case "dfn":
    collector.add(new Buzzword(jCas));
    break;
   case "address":
    collector.add(new Location(jCas));
    break;
   case "abbr":
    collector.add(new Buzzword(jCas));
    break;
   case "cite":
    collector.add(new DocumentReference(jCas));
    break;

   default:
    return;
  }
 }
}
origin: dstl/baleen

 @Test
 public void testMarked() throws UIMAException {
  Quantity q = new Quantity(jCas);
  q.setBegin(18);
  q.setEnd(21);
  q.addToIndexes();

  Buzzword e = new Buzzword(jCas);
  e.setBegin(25);
  e.setEnd(36);
  e.addToIndexes();

  processJCas();

  assertEquals(2, JCasUtil.select(jCas, Entity.class).size());

  assertEquals(1, JCasUtil.select(jCas, Relation.class).size());
  Relation r = JCasUtil.selectByIndex(jCas, Relation.class, 0);
  assertEquals(18, r.getBegin());
  assertEquals(q, r.getSource());
  assertEquals(36, e.getEnd());
  assertEquals(e, r.getTarget());
  assertEquals("QUANTITY", r.getRelationshipType());
 }
}
origin: uk.gov.dstl.baleen/baleen-collectionreaders

 @Override
 public void map(JCas jCas, Element element, AnnotationCollector collector) {
  switch (element.tagName().toLowerCase()) {
   case "time":
    collector.add(new Temporal(jCas));
    break;
   case "meter":
    collector.add(new Quantity(jCas));
    break;
   case "dfn":
    collector.add(new Buzzword(jCas));
    break;
   case "address":
    collector.add(new Location(jCas));
    break;
   case "abbr":
    collector.add(new Buzzword(jCas));
    break;
   case "cite":
    collector.add(new DocumentReference(jCas));
    break;

   default:
    return;
  }
 }
}
uk.gov.dstl.baleen.types.commonQuantity

Javadoc

Type to annotate references to quantities within text Updated by JCasGen Wed Apr 13 13:23:16 BST 2016 XML source: H:/git/TextProcessing/core/baleen/baleen-uima/src/main/resources/types/common_type_system.xml

Most used methods

  • <init>
  • addToIndexes
  • setBegin
  • setEnd
  • getBegin
  • getCoveredText
  • getEnd
  • getNormalizedQuantity
    getter for normalizedQuantity - gets The normalized quantity
  • getNormalizedUnit
    getter for normalizedUnit - gets The unit of the normalized quantity
  • getQuantity
    getter for quantity - gets The raw quantity
  • getSubType
  • getUnit
    getter for unit - gets The unit of the raw quantity
  • getSubType,
  • getUnit,
  • getValue,
  • readObject,
  • setConfidence,
  • setNormalizedQuantity,
  • setNormalizedUnit,
  • setQuantity,
  • setSubType,
  • setUnit

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top 12 Jupyter Notebook extensions
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