воскресенье, 8 августа 2010 г.

Похолодало



Сегодня был один из самых прохладных дней за все лето. Днем мой градусник показывал всего +45 на солнце (обычно все +50), а вечером температура упала до +33. На улице можно было дышать и даже гулять.

среда, 4 августа 2010 г.

First results of test - mp3 (id3v2)

Old ID3EndAnalyzer:

./Rammstein - Mann gegen Mann.mp3
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment
"[Xakep Online] ";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated
"2005";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"7096320";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1230225080";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"audio/mpeg",
"audio/mpeg";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title
"Mann gegen Mann";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./Rammstein - Mann gegen Mann.mp3";
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator
"Rammstein";
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#publisher
":nwlrb";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#averageBitrate
"128000";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels
"2";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#codec
"MP3";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"Rammstein - Mann gegen Mann.mp3";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate
"44100";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre
"Rock";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum
":bmqbh";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber
"2";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio",
"http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicPiece",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".
:bmqbh
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title
"Rosenrot";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicAlbum".
:nwlrb
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname
"LAME 3.90.3+mod";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact".


Generated Mp3EndAnalyzer by Translator:

./Rammstein - Mann gegen Mann.mp3
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"7096320";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1230225080";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"audio/mpeg",
"audio/mpeg";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title
"Mann gegen Mann";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./Rammstein - Mann gegen Mann.mp3";
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#publisher
":cdarz";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"Rammstein - Mann gegen Mann.mp3";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#composer
":hiddq";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre
"(17)";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#lyricist
":owkky";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum
":nwlrb";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#performer
":bmqbh";
http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber
"2";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicPiece",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".
:bmqbh
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname
"Rammstein";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contact".
:cdarz
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname
"LAME 3.90.3+mod";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contact".
:hiddq
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname
"Rammstein";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contact".
:nwlrb
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title
"Rosenrot";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicAlbum".
:owkky
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname
"";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contact".


Extractor test:
myvector stores 9 numbers.
Name=Publisher Value = LAME 3.90.3+mod
Name=Title Value = Mann gegen Mann
Name=Publisher Value = Po-X
Name=Genre Value = (17)
Name=Album Value = Rosenrot
Name=Performer Value = Rammstein
Name=Track_number Value = 2
Name=Composer Value = Rammstein
Name=Performer Value = Rammstein


TFL input file:

Format mp3;

Metadata: id3v2, id3v1;

if(id3v2)
{
Created = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated";
Subject = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject";
Title = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title";
Description = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description";
Comment = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment";
Artist = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator";
Album = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum";
Genre = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre";
Composer = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#composer";
Performer = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#performer";
Liricist = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#lyricist";
Publisher = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#publisher";
Language = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#landuage";
Copyright = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright";
Track_number = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber";
Duration = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#duration";
Bitrate = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#averageBitrate";
Samplerate = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate";
Codec = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#codec";
Channels = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels";


&type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
&fullname = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname";
&titleProperty = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title";
&albumTrackCount = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#albumTrackCount";
&discNumber = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#setNumber";
&discCount = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#setCount";
&musicClass = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicPiece";
&audioClass = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio";
&albumClass = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicAlbum";
&contactClass = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contact";

Uri a, a1, a2, a3, a4;

T: a1 - type - contactClass;
T: a1 - fullname - Performer;

T: a2 - type - contactClass;
T: a2 - fullname - Publisher;

T: a - titleProperty - Album;
T: a - type - albumClass;

T: a3 - type - contactClass;
T: a3 - fullname - Liricist;

T: a4 - type - contactClass;
T: a4 - fullname - Composer;


D: type - musicClass;
D: type - audioClass;

}


TL input file:

Binary id3v2;

ByteOrder=MSB;
BitOrder=MSB;

StartMetadataKey ID3(offset=0, size=3);
checkKey(ID3)="ID3";

MetadataKey HeaderFlag(start, offset=5, size=1);

MetadataKey ID3_size(start, offset=6, size=4);

MetadataSize=getNumber(ID3_size);

if (getBit(HeaderFlag, 6)==1)
{
MetadataKey ExHeaderSize(start, offset=10, size=4);
MetadataKey FirstFrameID(start, offset=getNumber(ExHeaderSize)+10, size=4);
MetadataSize-=(10+getNumber(ExHeaderSize));
}
else
MetadataKey FirstFrameID(start, offset=10, size=4);

key=FirstFrameID;
while(MetadataSize>0)
{
MetadataKey sizeOfTag(key, offset=0, size=4);
if(getByte(key, 0)==0x00)
{
break;
}
else {
TagSize=getNumber(sizeOfTag);
if((getValue(key)=="TALB" || getValue(key)=="TOAL") && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
SetTag Album(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TCOM" && (TagSize>1))
{
MetadataKey encoding(key, offset=6, size=1);
setTag Composer(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if((getValue(key)=="TYAR" || getValue(key)=="TDRL" || getValue(key)=="TDAT" || getValue(key)=="TDRC") && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Created(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TRCK" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Track_number(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TIT2" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Title(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TIT1" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Subject(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TIT3" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Description(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if((getValue(key)=="TPE1" || getValue(key)=="TPE2" || getValue(key)=="TPE3" || getValue(key)=="TPE4")&& TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Performer(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if((getValue(key)=="TPUB" || getValue(key)=="TENC")&& TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Publisher(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TEXT" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Liricist(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TCON" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Genre(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TLAN" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Language(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TCOP" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Copyright(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}
if(getValue(key)=="TLEN" && TagSize>1)
{
MetadataKey encoding(key, offset=6, size=1);
setTag Duration(getStringByLink(encoding, offset=0, size=getNumber(sizeOfTag)-1));
}

MetadataSize-=(10+getNumber(sizeOfTag));
shift(key, 6+getNumber(sizeOfTag));
}

}

First results of test - png

Old PngEndAnalyzer:

./2.png
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"145620";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1278429356";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"image/png",
"image/png";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./2.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth
"32";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"2.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height
"415";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode
"None";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width
"800";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".


Generated PngEndAnalyzer by Translator:

./2.png
http://freedesktop.org/standards/xesam/1.0/core#compressionAlgorithm
"6";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"145620";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1278429356";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"image/png",
"image/png";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./2.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator
":nwlrb";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth
"32";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"2.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height
"415";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode
"0";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width
"800";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".
:nwlrb
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname
"";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact".


Extractor test:
myvector stores 7 numbers.
Name=Width Value = 800
Name=Height Value = 415
Name=Color_type Value = 8
Name=Compression_method Value = 6
Name=ColorDept Value = 32
Name=Filter_method Value = 0
Name=Interlace_method Value = 0


TFL input file:

Format Png;

Metadata: PngChunk;


if(PngChunk)
{
Width = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width";
Height = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height";
ColorDepth= "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth";
Compression_method = "http://freedesktop.org/standards/xesam/1.0/core#compressionAlgorithm";
Interlace_method = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode";
Title="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title";
Author="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator";
Description="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description";
Copyright="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright";
Creation_time="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated";
Software="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator";
Dislaimer="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#disclaimer";
Warning="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment";
Source="http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model";
Comment="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment";

&type="http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
&fullname="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname";
&contactClass= "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact";
&rasterImage = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage";
Uri a;
T: a - type - contactClass;
T: a - fullname - Author;

D: type - rasterImage;

}


TL input file:

Binary PngChunk;

ByteOrder=MSB;
BitOrder=MSB;

StartMetadataKey MagicHex(offset=0, size=8);
checkKey(MagicHex)=0x89504e470d0a1a0a;

MetadataKey length(MagicHex, offset=0, size=4);
MetadataKey chunkname(length, offset=0, size=4);
MetadataKey data(chunkname, offset=0, size=getNumber(length));
MetadataKey crc(data, offset=0, size=4);

while(getValue(chunkname)!="IEND")
{
if(getValue(chunkname)=="IHDR")
{

MetadataKey width(chunkname, offset=0, size=4);
SetTag Width(getNumber(width));

MetadataKey height(width, offset=0, size=4);
SetTag Height(getNumber(height));

MetadataKey ColorType(height, offset=0, size=1);
SetTag Color_type(getNumber(ColorType));

MetadataKey Compression(ColorType, offset=0, size=1);
SetTag Compression_method(getNumber(Compression));

if(getNumber(Compression)==2)
{
n=3*getNumber(ColorType);
SetTag ColorDepth(n);
}

if(getNumber(Compression)==4)
{
n=2*getNumber(ColorType);
SetTag ColorDepth(n);
}

if(getNumber(Compression)==6)
{
n=4*getNumber(ColorType);
SetTag ColorDepth(n);
}

MetadataKey Filter(Compression, offset=0, size=1);
SetTag Filter_method(getNumber(Filter));

MetadataKey Interlace(Filter, offset=0, size=1);
SetTag Interlace_method(getNumber(Interlace));

}

if(getValue(chunkname)=="tEXt")
{
keyword=getStringByLink(chunkname,offset=0);
n=getLength(keyword);
datatext=getStringByLink(chunkname,offset=n+1);
if(keyword=="Title") SetTag Title(datatext);
if(keyword=="Author") SetTag Author(datatext);
if(keyword=="Description") SetTag Description(datatext);
if(keyword=="Copyright") SetTag Copyright(datatext);
if(keyword=="Creation Time") SetTag Creation_time(datatext);
if(keyword=="Software") SetTag Software(datatext);
if(keyword=="Disclaimer") SetTag Disclaimer(datatext);
if(keyword=="Warning") SetTag Warning(datatext);
if(keyword=="Source") SetTag Source(datatext);
if(keyword=="Comment") SetTag Comment(datatext);

}

oldlength=getNumber(length);
shift(length, 8+oldlength);
newlength=getNumber(length);
shift(chunkname, 8+oldlength);
shift(data, 12);
shift(crc, 8+newlength);

}

вторник, 3 августа 2010 г.

First results of test - bmp

Old bmpEndAnalyzer:

./test.bmp
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"921654";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1280740186";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"image/bmp",
"image/bmp";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./test.bmp";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth
"24";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"test.bmp";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height
"480";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width
"640";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".

Generated bmpEndAnalyzer by Translator:

./test.bmp
http://freedesktop.org/standards/xesam/1.0/core#formatSubtype
"Windows Bitmap";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"921654";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1280740186";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"image/bmp",
"image/bmp";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./test.bmp";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth
"24";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"test.bmp";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height
"480";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width
"640";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".


TFL input file:

Format Bmp;
Metadata: BmpInfoHeader;

if(BmpInfoHeader)
{
Type = "http://freedesktop.org/standards/xesam/1.0/core#formatSubtype";
Compression = "http://freedesktop.org/standards/xesam/1.0/core#compressionAlgorithm";
Width = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width";
Height = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height";
Color = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth";

&rdftype = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
&rasterImage = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage";

D: rdftype - rasterImage;

}


TL input file:

Binary BmpInfoHeader;

StartMetadataKey BM(offset=0, size=2);
checkKey(BM)="BM";

if(getString(BM)=="BM") SetTag Type("Windows Bitmap");

MetadataKey Width(start, offset=18, size=4);
SetTag Width(getNumber(Width));

MetadataKey Height(Width, offset=0, size=4);
SetTag Height(getNumber(Height));

MetadataKey BitCount(Height, offset=2, size=2);
SetTag Color(getNumber(BitCount));

MetadataKey Compression(BitCount, offset=0, size=4);
if(getNumber(Compression)==0) setTag Campression("None");
if(getNumber(Compression)==1) setTag Campression("RLE 8bit/pixel");
if(getNumber(Compression)==2) setTag Campression("RLE 4bit/pixel");
if(getNumber(Compression)==3) setTag Campression("Bit fields");

воскресенье, 1 августа 2010 г.

И даже работает...

Мы строили строили и наконец — запустили нормальный тест со стрижами, и даже что-то заработало.

Старый парсер выдает это для Png:
./test.png
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"49237";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1280592673";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"image/png",
"image/png";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./test.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth
"8";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"test.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height
"450";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode
"None";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width
"600";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage",
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".

Новый это:

./test.png
http://freedesktop.org/standards/xesam/1.0/core#compressionAlgorithm
"3";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize
"49237";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf
"";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified
"1280592673";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType
"image/png",
"image/png";
http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url
"./test.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator
":nwlrb";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth
"8";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName
"test.png";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height
"450";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode
"0";
http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width
"600";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject".
:nwlrb
http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname
"";
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
"http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact".


Не в десятку, но это уже минус входного файла — нужно сесть и все по-человечески доделать. Есть еще недоделки(большие и не очень) и баги, но тут два позитивных момента 1) я о них знаю 2) по ходу все можно доделать/исправить — не смертельно. Ура, начинаем тесты!!!!

четверг, 29 июля 2010 г.

TFL examples - mp3

Format mp3;

Metadata: id3v2, id3v1;

if(id3v2)
{
created = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated";
subject = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject";
title = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title";
description = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description";
comment = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment";
artist = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator";
album = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum";
genre = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre";
composer = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#composer";
performer = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#performer";
liricist = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#lyricist";
publisher = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#publisher";
language = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#landuage";
copyright = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright";
trackNumber = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber";
duration = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#duration";
bitrate = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#averageBitrate";
samplerate = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate";
codec = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#codec";
channels = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels";


&type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
&fullname = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname";
&titleProperty = "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title";
&albumTrackCount = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#albumTrackCount";
&discNumber = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#setNumber";
&discCount = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#setCount";
&musicClass = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicPiece";
&audioClass = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio";
&albumClass = "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicAlbum";
&contactClass = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contact";

Uri a, a1, a2, a3, a4, a5;

T: a1 - type - contactClass;
T: a1 - fullname - performer;

T: a2 - type - contactClass;
T: a2 - fullname - publisher;

T: a - titleProperty - album;
T: a - type - albumClass;

T: a3 - type - contactClass;
T: a3 - fullname - liricist;

T: a4 - type - contactClass;
T: a4 - fullname - composer;

T: a5- albumTrackCount - trackNumber;


}

среда, 14 июля 2010 г.

The first results

The goal of project it is a creating of parsers generator for Strigi. Input of generator it is two file. First – describing of metadata format, second – mapping (it is shows how is related tags of metadata and ontology). I separated it for two reasons: 1) one format can has two or more type of metadata (different version of metadata format or new universal formal like xmp) 2) testing grammar really simpler when it is separated.


My first step it is developing of a language for describing metadata format and language for describing the mapping. I created language base on png, exif, id3, vorbis comment and xmp (last 2 a little bit). The language for metadata it is Tag language (TL – short name) and it is contain main item MetadataKey. This is example for png (file pngchunk.txt)
/* key word Binary means that description starts and MetadataKey is defined by offset and size. I planned to expand the language for finding tag by key word and if it necessary it will start by Text key word.


PngChung it name and prefix for future class of extractor */
1 Binary PngChunk;
2

/* ByteOrder и BitOrder it is order a byte and bit. If it is not defined it will LSB.*/
3 ByteOrder=MSB;
4 BitOrder=MSB;
5

/*StartMetadataKey – it is the first key that define type of metadata. Offset for this key from beginning of file. */
6 StartMetadataKey IHDR(offset=12, size=4);
/* Checking value of key. It is required for StartMetadataKey and can to check a string or a hex value.*/
7 checkKey(IHDR)="IHDR";
8

/*MetadataKey –region that contains tag. It can defined by base key (or key word “start”), offset and size. If first parameter is “start” then offset for key from beginning of file. If first parameter is another MetadataKey the offset for key from end base key. */
9 MetadataKey width(IHDR, offset=0, size=4);
/* Creating tag with name “Widht” and with number value that is saved by MetadataKey. Currently I can get only string and int32 types. But I will expand it for double and int64 in future. */
10 SetTag Width(getNumber(width));
11
12 MetadataKey height(width, offset=0, size=4);
13 SetTag Height(getNumber(height));
14
15 MetadataKey ColorType(height, offset=0, size=1);
16 SetTag Color_type(getNumber(ColorType));
17
18 MetadataKey Compression(ColorType, offset=0, size=1);
19 SetTag Compression_method(getNumber(Compression));
20
21 MetadataKey Filter(Compression, offset=0, size=1);
22 SetTag Filter_method(getNumber(Filter));
23
24 MetadataKey Interlace(Filter, offset=0, size=1);
25 SetTag Interlace_method(getNumber(Interlace));


Additional functions:
getNumberByLink(key, offset, size) or getNumberByLink(offset, size) – get number by offset and size. If key is not defined offset from beginning of file.
getStringByLink(key, offset, size), getStringByLink( offset, size), getStringByLink(key, offset), getStringByLink( offset) – get string by offset. If key is not defined offset from beginning of file. If size is not defined it get all until symbol end of string or end of file.
getValueByLink(key, offset, size), getValueByLink(offset, size) – get data without type conversion. 9never used but exist).
All this function it is short variant of MetadataKey + getValue (getString, getNumber)

Functions:
shift(key,n) – moved key on n steps .
getBit(key,n) – get bit number n inside key.
getByte(key, n) – get byte number n inside key.
(You can fine examples of using these functions in files id3tag.txt и exif.txt)

And of course I implemented loop (currently only wile) and if- else

Language for mapping I called – Tiny Format language or shot TFL. For png example (file png_triplex.txt):
/* Format it is key word. After this key word follow prefix for EndAnalyzer class.*/
1 Format Png;
2

/* Metadata – key word defined list of name of formats metadata . Png has only one type of metadata – it PngChunk*/
3 Metadata: PngChunk;
4
5

/* It checking StartMetadataKey. If it is true then triplex creates according to mapping inside this if .*/
6 if(PngChunk)
7 {
/* The name of tag here has to be same name of tag that was been created by setTag function in file pngchunk.txt */
8 With = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width";
9 Height = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height";
10 Color_type= "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth";
11 Compression_method = "http://freedesktop.org/standards/xesam/1.0/core#compressionAlgorithm";
12 Interlace_method = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode";
13
14 }



Second step it is writing of translator for TFL and TL languages. Each translator contains scanner, parser and generator of c++ code. For developing of scanner and parser I used coco/r generator. It doesn’t have tool for testing and debug grammar (like AntlrWorks for antlr) but it has more clear documentation. The result of working of the TL translator it is class extractor which extracts tag and saves it in vector of Tag.


/*files PngChunkextractor.h и PngChunkextractor.cpp after working TL translator*/
1 #ifndef PngChunkExtractor_H_
2 #define PngChunkExtractor_H_
3 #include "MetadataKey.h"
4 #include "Tag.h"
5 #include "MetadataFunc.h"
6 #include
7 #include
8
9
10 class PngChunkExtractor {
11 public:
12 PngChunkExtractor(std::ifstream _is) {is=_is;}
13 std::vector toExtract();
14 bool toCheck();
15 private:
16 std::ifstream is;
17 };
18 #endif


The result of working of the TFL translator it is class inheritance from StreamEndAnalyzer class.


/* files Pngendanalyzer.h и Pngendanalyzer.cpp after working of TFL translator */
1 #include "Pngendanalyzer.h"
2 #include
3
4
5 void PngEndAnalyzerFactory::registerFields(FieldRegister& reg) {
6 RF["PngChunk_Color_typeField"]=reg.registerField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth");
7 addField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth");
8 RF["PngChunk_Compression_methodField"]=reg.registerField("http://freedesktop.org/standards/xesam/1.0/core#compressionAlgorithm");
9 addField("http://freedesktop.org/standards/xesam/1.0/core#compressionAlgorithm");
10 RF["PngChunk_HeightField"]=reg.registerField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height");
11 addField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height");
12 RF["PngChunk_Interlace_methodField"]=reg.registerField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode");
13 addField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode");
14 RF["PngChunk_WithField"]=reg.registerField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width");
15 addField("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width");
16 }
17
18
19 signed char PngEndAnalyzer::analyze(AnalysisResult& as, InputStream* in) {
20 int flag=-1;
21 PngChunkExtractor PngChunk(InputStream* in);
22 if(PngChunk.toCheck()){
23 std::vector tag_v=PngChunk.toExtract();
24 flag=0;
25 for(int i=0; igetField(name), t.getNumber()); break;
34 case 2: as.addValue(factory->getField(name), t.getString()); break;
35 }
36 name.clear();
37 }
38 return flag;
39 }


Next steps:
1. To rewrite the MetadataKey for working with InputStream (I think I have done it, but didn’t test well)
2. To add opportunity in TL language to get double type.
3. To add in TFL triplex creating.
4. To add the message about declaration error, encoding and another things that I missed.

Link:
http://gitorious.org/strigi/strigi-grammar/trees/master/Translator