本文整理汇总了Java中it.uniroma1.lcl.jlt.util.Strings类的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Strings类属于it.uniroma1.lcl.jlt.util包,在下文中一共展示了Strings类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStanfordSentence
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
/**
* returns
* @param sentence
* input sentence, space delimited
* @param discardStopWords
* true if stopwords are to be discarded from the sentence
* @return
* a pair containing <list of word-pos, remaining not-handled terms>
*
*/
public Pair<List<String>, List<String>> getStanfordSentence(String sentence)
{
List<WordLemmaTag> wlts = SentenceProcessor.getInstance().processSentence(sentence, false);
List<String> terms = null;
StanfordSentence sSentence = StanfordSentence.fromLine(Strings.join(wlts," "));
try
{
terms = sSentence.getTerms(TAGS,
Language.EN,
null,
MultiwordBelongingTo.WORDNET,
CompoundingParameter.ALLOW_MULTIWORD_EXPRESSIONS,
CompoundingParameter.APPEND_POS);
}
catch(Exception e)
{
e.printStackTrace();
}
//discards OOVs, and tries to map incorrect pos-tags to the correct ones
return fixTerms(terms, discardStopwords);
}
示例2: getConcepts
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
public void getConcepts() throws IOException
{
int counter = 0;
Timer timer = new Timer();
for (String concept : concepts)
{
Set<List<String>> paths = kb.getAllPathsFrom(concept, maxSearchDepth);
FileWriter writerFrom = dirManager.getFileWriter(concept+".txt");
// saves the paths starting from the concept
for (List<String> path : paths)
writerFrom.write(Strings.join(path)+"\n");
writerFrom.close();
if ((counter%100)==0)
timer.tick("\t[WORKER] " + id +
" TO CREATE INDEXABLE FILES FOR " +
counter + " CONCEPTS SO FAR ... ");
counter++;
}
}
示例3: toString
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
@Override
public String toString()
{
return
new StringBuffer().
append(Strings.format(confidence)).append("_").
append(numberOfTranslations).append("_").
append(sampleSize).toString();
}
示例4: toString
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
@Override
public String toString()
{
return
new StringBuffer().
append(language).append("_").
append(pointer.getSymbol()).append("_").
append(target).append("_").
append(Strings.format(weight)).append("_").
append(Strings.format(normalizedWeight)).toString();
}
示例5: printDegree
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
/**
* Prints information about the degree of a {@link KnowledgeGraph} with a
* specific scorer
*
* @param simpleGraph
* @param kb
*/
public static void printDegree(KnowledgeGraph simpleGraph, KnowledgeBase kb)
{
StringBuffer buffer = new StringBuffer();
Collection<String> concepts = simpleGraph.getConceptsForSourceWords();
DirectedGraph<String, WeightedLabeledEdge> graph = simpleGraph.getGraph();
for (String concept : concepts)
{
double weightedSum = 0.0;
int degree = graph.outDegreeOf(concept);
Multimap<IPointer, ScoredItem<String>> related = kb.getRelatedConceptsMap(concept);
buffer.append("\n OFFSET = ").append(concept).append(" SENSE = ").append(kb.conceptToString(concept)).append("\n\n OUTGOING EDGES\n");
for (WeightedLabeledEdge edge : graph.outgoingEdgesOf(concept))
{
weightedSum += edge.getWeight();
String src = graph.getEdgeSource(edge);
String target = graph.getEdgeTarget(edge);
buffer.append("\n ").append(kb.conceptToString(src)).append(":").append(edge.getLabel()).append("[").append(edge.getWeight()).append("]:").append(kb.conceptToString(target));
}
buffer.append("\n ==============================");
buffer.append("\n DEGREE: ").append(degree).append("/").append(related.size()).append("=").append(Strings.format((double) degree / (double) related.size()))
.append(" -- WEIGHTED SUM: ").append(Strings.format(weightedSum)).append("/").append(related.size()).append("=")
.append(Strings.format((double) weightedSum / (double) related.size()));
buffer.append("\n ==============================");
}
log.info(buffer);
}
示例6: BabelImage
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
/**
* Creates a new instance of {@link BabelImage}
*
* @param imageName
* the MediaWiki page name for the image - something like
* "LANGUAGE:Image:..."
*/
public BabelImage(String imageName)
{
boolean bSpecialImage = false;
// identifies the language
int colonIdx = imageName.indexOf(":");
if (colonIdx == -1)
throw new RuntimeException("Invalid image name: " + imageName);
Language language = Language.valueOf(imageName.substring(0, colonIdx));
// removes trailing "File:" or "Image:"
String cleanImageName = imageName.substring(colonIdx+1);
colonIdx = cleanImageName.indexOf(":");
if (colonIdx != -1) cleanImageName = cleanImageName.substring(colonIdx+1);
//se è un'image particolare ha un tag in più
if(cleanImageName.startsWith("MANUAL:"))
{
bSpecialImage = true;
colonIdx = cleanImageName.indexOf(":");
if (colonIdx != -1) cleanImageName = cleanImageName.substring(colonIdx+1);
cleanImageName = Strings.forceFirstCharUppercase(cleanImageName);
}
else cleanImageName = Strings.forceFirstCharUppercase(cleanImageName);
// e.g. "Paula_Radcliffe.jpg"
this.name = cleanImageName.trim();
//System.out.println("name "+name);
this.badImage = BadImageList.getInstance().isBadImage(name);
// Language.EN for instance
this.language = language;
if(bSpecialImage)
{
this.thumbUrl = cleanImageName;
this.url = cleanImageName;
}
else
{
this.thumbUrl = createThumbURL(name);
this.url = createURL(name);
}
}
示例7: getValidatedURL
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
private String getValidatedURL(boolean isThumb)
{
// try the "base" search first
// otherwise check whether it's a redirection
//
// e.g. http://en.wikipedia.org/wiki/File:Cheese_07_bg_042906.jpg
if (!isThumb)
if (urlValidated != null) return urlValidated;
else
if (urlThumbValidated != null) return urlThumbValidated;
String url = null;
int sizeSmall = 0;
try
{
URI uri = new URI(
"http",
EN_WIKIPEDIA_HOST,
EN_WIKIPEDIA_PATH+"File:"+name,
null);
String wikiUrl = uri.toASCIIString();
// get the page content
ByteArrayOutputStream os = new ByteArrayOutputStream();
WGet.wGet(wikiUrl, os);
String content = os.toString();
// check for a URL labeled as "canonical"
Matcher matcher = CANONICAL_PATTERN.matcher(content);
if (matcher.find())
{
// got it, e.g. File:Mozzarella_cheese.jpg
String redirectedName = matcher.group(1);
String cleanRedirectedName = redirectedName;
int colonIdx = redirectedName.indexOf(":");
if (colonIdx != -1) cleanRedirectedName = cleanRedirectedName.substring(colonIdx+1);
cleanRedirectedName =
Strings.forceFirstCharUppercase(cleanRedirectedName).trim();
Pattern sizePatt = Pattern.compile("=\"(//upload.wikimedia.org/wikipedia/(commons|"+this.language.toString().toLowerCase()+")/thumb/(?!archive).*?"+cleanRedirectedName+""+"/([0-9]*?)px-"+cleanRedirectedName+".*?)\"");
Matcher matcherSize = sizePatt.matcher(content);
while (matcherSize.find())
{
//Se sono qui vuol dire che il thumb non è stato validato,
//prende l'indirizzo più piccolo vicino alla grandezza desiderata
if(Integer.parseInt(matcherSize.group(3)) <= imageSize)
if (sizeSmall < Integer.parseInt(matcherSize.group(3))) {
if(matcherSize.group(1).startsWith("//"))
url = "http:"+matcherSize.group(1);
else
url = matcherSize.group(1);
sizeSmall = Integer.parseInt(matcherSize.group(3));
}
}
// create the redirection's URL and check it exists
String redirectedURL = createURL(cleanRedirectedName);
urlValidated = getValidatedURL(redirectedURL, language);
//se non trova nulla imposta l'url originale validato
if(url == null) url = urlValidated;
// create the thumb URL
urlThumbValidated = url;
// if validate thumbs
if (!isThumb) return urlValidated;
else return urlThumbValidated;
}
return null;
}
catch (URISyntaxException e)
{
return null;
}
}
示例8: toString
import it.uniroma1.lcl.jlt.util.Strings; //导入依赖的package包/类
@Override
public String toString()
{
return "("+src+","+pointerSymbol+":"+Strings.format(weight)+","+target+")";
}