本文整理汇总了Java中de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi.getRevision方法的典型用法代码示例。如果您正苦于以下问题:Java RevisionApi.getRevision方法的具体用法?Java RevisionApi.getRevision怎么用?Java RevisionApi.getRevision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi
的用法示例。
在下文中一共展示了RevisionApi.getRevision方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRevisionForTimestamp
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
/**
* Returns the revision of an article at a particular age
*
* @param articleId id of the article
* @param tagetTS we are looking for a revision created at or right after the provided timestamp
* @param revApi revisionApi object
* @return the revision object, if it exists. null, else
*/
public static Revision getRevisionForTimestamp(int articleId, Timestamp targetTS, RevisionApi revApi) throws WikiApiException{
DateTime targetDT = new DateTime(targetTS);
Timestamp prevTS=null;
for(Timestamp curTS:revApi.getRevisionTimestamps(articleId)){
DateTime curDT = new DateTime(curTS);
if(curDT.isEqual(targetDT)){
return revApi.getRevision(articleId, curTS);
}
if(curDT.isAfter(targetDT)&&prevTS!=null){
return revApi.getRevision(articleId, prevTS);
}
prevTS=curTS;
}
return null;
}
示例2: getRevisionByTimestampTest
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
@Test
public void getRevisionByTimestampTest()
{
Calendar calendar = Calendar.getInstance();
calendar.set(2008, 10, 10, 10, 10, 10);
String pageName = "Car";
try {
RevisionApi revisionApi = new RevisionApi(
wiki.getDatabaseConfiguration());
int pageId = wiki.getPage(pageName).getPageId();
Timestamp timestamp = new Timestamp(calendar.getTimeInMillis());
Revision revision = revisionApi.getRevision(pageId, timestamp);
assertEquals(1142935, revision.getRevisionID());
assertEquals(0, revision.getFullRevisionID());
assertEquals(349, revision.getRevisionCounter());
assertEquals(pageId, revision.getArticleID());
}
catch (WikiApiException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例3: lastRevisionTest
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
public void lastRevisionTest()
{
Calendar calendar = Calendar.getInstance();
calendar.set(2008, 10, 10, 10, 10, 10);
String pageName = "Car";
try {
RevisionApi revisionApi = new RevisionApi(
wiki.getDatabaseConfiguration());
int pageId = wiki.getPage(pageName).getPageId();
Timestamp lastRevisionTimestamp = revisionApi
.getLastDateOfAppearance(pageId);
Revision revision = revisionApi.getRevision(pageId,
lastRevisionTimestamp);
assertEquals(wiki.getPage(pageId).getText(),
revision.getRevisionText());
}
catch (WikiApiException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例4: TalkPage
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
/**
* @param revApi
* RevisionApi instance
* @param revId
* talk page revision to process
* @param aggregateParagraphs
* whether to aggregate paragraphs to turns (true) or to consider
* paragraphs as turns on their own (false)
*/
public TalkPage(RevisionApi revApi, int revId, boolean aggregateParagraphs) {
this.aggregateParagraphs = aggregateParagraphs;
this.revApi=revApi;
try {
tpBaseRevision = revApi.getRevision(revId);
} catch (WikiApiException e) {
logger.error("Error checking revisions of origin for paragraphs. Could not process revision. Error accessing Wikipedia database with revision API",e);
}
_revisionSegmentParagraphs();
_buildTurnsFromParagraphs();
}
示例5: getRevisionForAge
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
/**
* Returns the revision of an article at a particular age
*
* @param articleId id of the article
* @param creationTS explicitly defines the creation TimeStamp from where to count (e.g. if we want to retrieve the revision of the TalkPage based on the age of the article Page)
* @param ageInDays age in days
* @param revApi revisionApi object
* @return the revision object, if it exists. null, else
*/
public static Revision getRevisionForAge(int articleId, Timestamp creationTS, int ageInDays, RevisionApi revApi) throws WikiApiException{
DateTime creation = new DateTime(creationTS);
DateTime version = creation.withFieldAdded(DurationFieldType.days(), ageInDays);
for(Timestamp curTS:revApi.getRevisionTimestamps(articleId)){
DateTime curDT = new DateTime(curTS);
if(curDT.isEqual(version)||curDT.isAfter(version)){
return revApi.getRevision(articleId, curTS);
}
}
return null;
}
示例6: getRevisionBeforeTimestamp
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
/**
* Returns the revision of an article at a particular age
*
* @param articleId id of the article
* @param tagetTS we are looking for a revision created at or right after the provided timestamp
* @param revApi revisionApi object
* @return the revision object, if it exists. null, else
*/
public static Revision getRevisionBeforeTimestamp(int articleId, Timestamp targetTS, RevisionApi revApi) throws WikiApiException{
DateTime targetDT = new DateTime(targetTS);
Timestamp prevTS=null;
for(Timestamp curTS:revApi.getRevisionTimestamps(articleId)){
DateTime curDT = new DateTime(curTS);
if((curDT.isEqual(targetDT)||curDT.isAfter(targetDT))&&prevTS!=null){
return revApi.getRevision(articleId, prevTS);
}
prevTS=curTS;
}
return null;
}
示例7: getRevisionByRevisionId
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
@Test
public void getRevisionByRevisionId()
{
Calendar calendar = Calendar.getInstance();
calendar.set(2008, 10, 10, 10, 10, 10);
try {
RevisionApi revisionApi = new RevisionApi(
wiki.getDatabaseConfiguration());
int pageId = wiki.getPage("Car").getPageId();
Timestamp timestamp = new Timestamp(calendar.getTimeInMillis());
Revision revision1 = revisionApi.getRevision(1142935);
Revision revision2 = revisionApi.getRevision(pageId, timestamp);
assertEquals(1142935, revision1.getRevisionID());
assertEquals(0, revision1.getFullRevisionID());
assertEquals(349, revision1.getRevisionCounter());
assertEquals(revision1.getRevisionID(), revision2.getRevisionID());
assertEquals(revision1.getFullRevisionID(),
revision2.getFullRevisionID());
assertEquals(revision1.getRevisionCounter(),
revision2.getRevisionCounter());
assertEquals(revision1.getArticleID(), revision2.getArticleID());
}
catch (WikiApiException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例8: getRevisionByRevisionCounter
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
@Test
public void getRevisionByRevisionCounter()
{
Calendar calendar = Calendar.getInstance();
calendar.set(2008, 10, 10, 10, 10, 10);
try {
RevisionApi revisionApi = new RevisionApi(
wiki.getDatabaseConfiguration());
int pageId = wiki.getPage("Car").getPageId();
Timestamp timestamp = new Timestamp(calendar.getTimeInMillis());
Revision revision1 = revisionApi.getRevision(pageId, 349);
Revision revision2 = revisionApi.getRevision(pageId, timestamp);
assertEquals(1142935, revision1.getRevisionID());
assertEquals(0, revision1.getFullRevisionID());
assertEquals(349, revision1.getRevisionCounter());
assertEquals(revision1.getRevisionID(), revision2.getRevisionID());
assertEquals(revision1.getFullRevisionID(),
revision2.getFullRevisionID());
assertEquals(revision1.getRevisionCounter(),
revision2.getRevisionCounter());
assertEquals(revision1.getArticleID(), revision2.getArticleID());
}
catch (WikiApiException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例9: extractTemplates
import de.tudarmstadt.ukp.wikipedia.revisionmachine.api.RevisionApi; //导入方法依赖的package包/类
/**
* Extracts templates from pages and revisions
*/
private void extractTemplates() throws WikiApiException
{
PageIterator pageIter = new PageIterator(getWiki(), true, pageBuffer);
RevisionApi revApi = new RevisionApi(dbConf);
int pageCounter = 0;
long revisionCounter =0L;
while (pageIter.hasNext()) {
pageCounter++;
if (pageCounter % VERBOSITY == 0) {
logger.info(pageCounter + " pages processed ...");
}
Page curPage = pageIter.next();
int curPageId = curPage.getPageId();
//PROCESS PAGES
if (mode.active_for_pages) {
fillMapWithTemplateData(curPage.getText(), pageFilter, curPageId,
TPLNAME_TO_PAGEIDS);
}
//PROCESS REVISIONS
if (mode.active_for_revisions) {
List<Timestamp> tsList = revApi.getRevisionTimestamps(curPageId);
for(Timestamp ts:tsList){
revisionCounter++;
if (revisionCounter % (VERBOSITY*10) == 0) {
logger.info(revisionCounter + " revisions processed ...");
}
Revision curRevision = revApi.getRevision(curPageId, ts);
int curRevisionId = curRevision.getRevisionID();
fillMapWithTemplateData(curRevision.getRevisionText(),
revisionFilter, curRevisionId, TPLNAME_TO_REVISIONIDS);
}
}
}
}