Tabnine Logo
TextConstraint.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.stanbol.entityhub.servicesapi.query.TextConstraint
constructor

Best Java code snippets using org.apache.stanbol.entityhub.servicesapi.query.TextConstraint.<init> (Showing top 20 results out of 315)

origin: apache/stanbol

  return null;
} else {
  return new TextConstraint((String)null,langs);
origin: org.apache.stanbol/org.apache.stanbol.entityhub.core

  return null;
} else {
  return new TextConstraint((String)null,langs);
origin: apache/stanbol

/**
 * @param rQuery
 * @param query
 */
private void addNameConstraint(ReconcileQuery rQuery, FieldQuery query) {
  //maybe an other column was also mapped to the NAME_FIELD property
  Collection<ReconcileValue> additionalValues = rQuery.removeProperty(NAME_FIELD);
  List<String> values;
  if(additionalValues == null){
    values = Collections.singletonList(rQuery.getQuery());
  } else {
    values = new ArrayList<String>(additionalValues.size()+1);
    values.add(rQuery.getQuery());
    for(ReconcileValue value : additionalValues){
      if(value != null && value.getValue() instanceof String){
        values.add((String)value.getValue());
      }
    }
  }
  query.setConstraint(NAME_FIELD, new TextConstraint(values));
}
/**
origin: apache/stanbol

  query.setConstraint(field, new TextConstraint(name, PatternType.wildcard, false));
} else {
  query.setConstraint(field, new TextConstraint(name, PatternType.wildcard, false, language));
origin: apache/stanbol

query.setConstraint(field, new TextConstraint(search, languages));
return query;
origin: apache/stanbol

protected QueryResultList<Entity> query(Site dbpediaSite, String savedEntityLabel, String language,
    String extractionContext) throws SiteException {
  FieldQuery query = dbpediaSite.getQueryFactory().createFieldQuery();
  if (savedEntityLabel != null && !savedEntityLabel.isEmpty()) {
    Constraint labelConstraint;
    if (language != null) {
      labelConstraint = new TextConstraint(savedEntityLabel, false, language, null);
    } else {
      labelConstraint = new TextConstraint(savedEntityLabel, false);
    }
    // TODO: what happens if a recommendation was not based on rdfs:label?
    query.setConstraint(RDFS_LABEL.getUnicodeString(), labelConstraint);
  } else {
    log.warn("parsed label {} was empty or NULL. Will use Similarity constraint only!",
      savedEntityLabel);
  }
  query.setConstraint(SpecialFieldEnum.fullText.getUri(), new SimilarityConstraint(extractionContext));
  query.setLimit(25);
  return dbpediaSite.findEntities(query);
}
origin: apache/stanbol

  fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
fieldMapper.addMapping(new FieldMapping(new TextConstraint(
  (String)null, langs.toArray(new String[langs.size()]))));
origin: apache/stanbol

query.setConstraint("urn:field3", new TextConstraint("\"quote",PatternType.none, true, "en", null));
origin: apache/stanbol

    query.setConstraint(property.getName(), new TextConstraint(texts));
    if (ids.size() != propertyEntry.getValue().size()) {
      log.info("Only some of the parsed values of the field {} are"
TextConstraint textConstraint = new TextConstraint(fullText);
query.setConstraint(SpecialFieldEnum.fullText.getUri(), textConstraint);
origin: org.apache.stanbol/org.apache.stanbol.entityhub.query.sparql

query.setConstraint("urn:field3", new TextConstraint("\"quote",PatternType.none, true, "en", null));
origin: apache/stanbol

TextConstraint constraint;
if(text.getLanguage() == null){
  constraint = new TextConstraint(text.getText(), PatternType.none, true);
} else {
  constraint = new TextConstraint(text.getText(), PatternType.none, true,text.getLanguage());
origin: apache/stanbol

@Test
public void testFindTextWildcards(){
  //init the test data
  FieldQueryTestData data = getFieldQueryTestData();
  //prefix search with *
  FieldQuery query = getYard().getQueryFactory().createFieldQuery();
  String wildcard = data.textValue1.getText();
  wildcard = wildcard.substring(0, wildcard.length()-1) + "*";
  query.setConstraint(data.textField, new TextConstraint(wildcard,PatternType.wildcard,false, "en"));
  query.addSelectedField(data.refField);
  query.addSelectedField(data.textField);
  validateQueryResults(query, getYard().find(query), 
      Arrays.asList(data.r1en.getId(), data.r2en.getId()), 
      Arrays.asList(data.refField, data.textField));
  
  //wildcard with ?
  query = getYard().getQueryFactory().createFieldQuery();
  //selects r1en and r2en
  wildcard = data.textValue1.getText();
  wildcard = wildcard.substring(0, wildcard.length()-1) + "?";
  query.setConstraint(data.textField, new TextConstraint(wildcard,PatternType.wildcard,false, "de"));
  query.addSelectedField(data.refField);
  query.addSelectedField(data.textField);
  validateQueryResults(query, getYard().find(query), 
      Arrays.asList(data.r1de.getId(), data.r2de.getId()), 
      Arrays.asList(data.refField, data.textField));
}

origin: apache/stanbol

/**
 * Same as {@link #testFindText()} but using 
 * {@link Yard#findRepresentation(FieldQuery)} to execute the queries
 */
@Test
public void testFindRepresentationText(){
  //init the test data
  FieldQueryTestData data = getFieldQueryTestData();
  //query for all languages and value1
  FieldQuery query = getYard().getQueryFactory().createFieldQuery();
  query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText()));
  validateQueryResults(query, getYard().findRepresentation(query), 
      Arrays.asList( data.r1.getId(), data.r1en.getId(), data.r1de.getId()), 
      Arrays.asList(data.textField, data.refField, data.intField));
  
  //same for value2
  query = getYard().getQueryFactory().createFieldQuery();
  query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText()));
  validateQueryResults(query, getYard().findRepresentation(query), 
      Arrays.asList( data.r2.getId(), data.r2en.getId(), data.r2de.getId()), 
      Arrays.asList(data.textField, data.refField, data.intField));
}
/**
origin: apache/stanbol

TextConstraint tc = new TextConstraint(search, languages);
tc.setProximityRanking(true); //STANBOL-1104
query.setConstraint(field.getUnicodeString(),tc);
origin: apache/stanbol

query.setConstraint(data.textField, new TextConstraint(
    Arrays.asList(data.textValue1.getText(), data.textValue2.getText()),
    "en"));
query.setConstraint(data.textField, new TextConstraint(
    Arrays.asList(data.textValue1.getText(), data.textValue2.getText()),
    "en", "de"));
origin: apache/stanbol

/**
 * Test a simple {@link TextConstraint} for any language
 */
@Test
public void testFindText(){
  //init the test data
  FieldQueryTestData data = getFieldQueryTestData();
  //query for all languages and value1
  FieldQuery query = getYard().getQueryFactory().createFieldQuery();
  query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText()));
  query.addSelectedField(data.textField);
  query.addSelectedField(data.refField);
  validateQueryResults(query, getYard().find(query), 
      Arrays.asList( data.r1.getId(), data.r1en.getId(), data.r1de.getId()), 
      Arrays.asList(data.textField, data.refField));
  
  //same for value2
  query = getYard().getQueryFactory().createFieldQuery();
  query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText()));
  query.addSelectedField(data.textField);
  query.addSelectedField(data.refField);
  validateQueryResults(query, getYard().find(query), 
      Arrays.asList( data.r2.getId(), data.r2en.getId(), data.r2de.getId()), 
      Arrays.asList(data.textField, data.refField));
}
/**
origin: apache/stanbol

/**
 * Same as {@link #testFindText()} but using 
 * {@link Yard#findReferences(FieldQuery)} to execute the queries
 */
@Test
public void testFindReferencesText(){
  //init the test data
  FieldQueryTestData data = getFieldQueryTestData();
  //query for all languages and value1
  FieldQuery query = getYard().getQueryFactory().createFieldQuery();
  query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText()));
  validateQueryResults(query, getYard().findReferences(query), 
      Arrays.asList(data.r1.getId(), data.r1en.getId(), data.r1de.getId()));
  
  //same for value2
  query = getYard().getQueryFactory().createFieldQuery();
  query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText()));
  validateQueryResults(query, getYard().findReferences(query),
      Arrays.asList( data.r2.getId(), data.r2en.getId(), data.r2de.getId()));
}
origin: apache/stanbol

query.setConstraint(data.textField, new TextConstraint(
    data.textValue1.getText(), "en"));
query.addSelectedField(data.textField);
query.setConstraint(data.textField, new TextConstraint(
    data.textValue2.getText(), "de"));
query.addSelectedField(data.textField);
query.setConstraint(data.textField, new TextConstraint(
    data.textValue1.getText(), (String)null));
query.addSelectedField(data.textField);
query.setConstraint(data.textField, new TextConstraint(
    data.textValue1.getText(), null, "en"));
query.addSelectedField(data.textField);
query.setConstraint(data.textField, new TextConstraint(
    data.textValue1.getText(), "en", "de"));
query.addSelectedField(data.textField);
origin: apache/stanbol

query.setConstraint(data.textField, new TextConstraint(wildcard,PatternType.wildcard,false, "en"));
query.setConstraint(data.textField, new TextConstraint(wildcard,PatternType.wildcard,false, "de"));
origin: apache/stanbol

/**
 * Gets an Entity from the configured {@link Site} based on the NER text and type.
 * 
 * @param ner
 * @param language
 * @return
 * @throws EngineException
 */
private Entity lookupEntity(Span ner, String language) throws EngineException {
  Site site = getReferencedSite();
  FieldQueryFactory queryFactory = site == null ? entityHub.getQueryFactory() : site.getQueryFactory();
  FieldQuery query = queryFactory.createFieldQuery();
  Constraint labelConstraint;
  String namedEntityLabel = ner.getSpan();
  labelConstraint = new TextConstraint(namedEntityLabel, false, language, null);
  query.setConstraint(RDFS_LABEL.getUnicodeString(), labelConstraint);
  query.setConstraint(RDF_TYPE.getUnicodeString(),
    new ReferenceConstraint(ner.getAnnotation(NlpAnnotations.NER_ANNOTATION).value().getType()
        .getUnicodeString()));
  query.setLimit(1);
  QueryResultList<Entity> results = site == null ? // if site is NULL
  entityHub.findEntities(query)
      : // use the Entityhub
      site.findEntities(query); // else the referenced site
  if (results.isEmpty()) return null;
  // We set the limit to 1 so if it found anything it should contain just 1 entry
  return results.iterator().next();
}
org.apache.stanbol.entityhub.servicesapi.queryTextConstraint<init>

Javadoc

Creates a TextConstraint for a text and languages.

Popular methods of TextConstraint

  • getLanguages
    The set of languages for this query.
  • getTexts
    Getter for the text constraints. Multiple constraints need to be connected with OR. For AND simple p
  • getPatternType
    The pattern type to be used for this query.
  • isCaseSensitive
    If the query is case sensitive
  • isProximityRanking
    Getter for the Term Proximity state. If enabled the proximity of the parsed terms should be used to
  • setProximityRanking
    Setter for the proximity ranking state. If enabled the proximity of the parsed terms should be used

Popular in Java

  • Updating database using SQL prepared statement
  • putExtra (Intent)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • compareTo (BigDecimal)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Collectors (java.util.stream)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • 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