See https://github.com/wardbekker/compression/blob/master/src/compression.erl for latest and greatest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_facet(Id, "Tags", AttributeValue) -> | |
{match, Captured} = re:run(AttributeValue, "<(.*?)>", [global, {capture, all_but_first, list}]), | |
lists:foreach( fun(Match) -> facet_ser:add_facet_value( "Tags", Match, Id) end, Captured); | |
add_facet(Id, "CreationDate", AttributeValue) -> | |
[ Date | _Time ] = string:tokens(AttributeValue, "T"), | |
facet_ser:add_facet_value("CreationDate", Date, Id); | |
add_facet(_,_,_) -> | |
ignore. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do_async_query(Terms, FacetCategories, Mod, Fun, Ref) -> | |
gen_server:cast( | |
?SERVER, | |
{ get_results, Terms, FacetCategories, Mod, Fun, Ref } | |
). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handle_cast({ get_results, Terms, FacetCategories, Mod, Fun, Ref }, State) -> | |
TermResults = keyword_ser:do_query(Terms), | |
{DocumentIds, Scores} = lists:unzip(TermResults), | |
Documents = gen_server:call(document_ser, {get_documents, DocumentIds}), | |
erlang:apply( Mod, Fun, [{docs, lists:zip(Scores, Documents) }, Ref]), | |
FacetResults = lists:map( | |
fun(Category) -> | |
{ Category, facet_ser:get_facets(Category, DocumentIds)} | |
end, | |
FacetCategories |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
term_document_score(NumberOfTimesTermAppearsInDocument, NumberOfDocumentsWithTerm, AverageDocumentLength, TotalNumberOfDocuments) -> | |
TermFrequency = term_frequency( NumberOfTimesTermAppearsInDocument, AverageDocumentLength), | |
Idf = important_document_frequency_of_term( TotalNumberOfDocuments, NumberOfDocumentsWithTerm ), | |
TermFrequency * Idf. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handle_websocket(Ws) -> | |
receive | |
{browser, Data} -> | |
Ws:send(["performing query'", Data, "'"]), | |
query_ser:do_async_query( | |
string:tokens(Data, " "), | |
["Tags", "CreationDate"], | |
?MODULE, | |
query_results, | |
[Ws] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_results({docs, Documents}, [Ws]) -> | |
%% create a nice list of results with scores. | |
Ws:send(["got doc results"]), | |
Partial = "<li><strong>Id:</strong> ~p<br /> | |
<strong>Score:</strong> ~p<br /> | |
<strong>Title:</strong> ~ts<br /> | |
<strong>Body:</strong> ~ts</li>", | |
Html = lists:map( | |
fun({Score, Attributes}) -> | |
io_lib:format( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_results({facet_results, [{"Tags", Tags}, {"CreationDate", _CreationDate}]}, [Ws]) -> | |
Html = lists:map( | |
fun({[Tag], Count}) -> | |
io_lib:format( | |
"<li>~ts ( ~p ) </li>", | |
[Tag, Count] | |
) | |
end, | |
Tags | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(user_default). | |
-author('[email protected]'). | |
%% Compile this file and use this line in your ~/.erlang file (with | |
%% correct path, of course!) to where the user_default.beam file is stored. | |
%% | |
%% code:load_abs("/home/fritchie/erlang/user_default"). | |
-export([help/0,dbgtc/1, dbgon/1, dbgon/2, | |
dbgadd/1, dbgadd/2, dbgdel/1, dbgdel/2, dbgoff/0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; taken from http://www.emacswiki.org/emacs/EightyColumnRule by http://www.emacswiki.org/emacs/TimOCallaghan | |
(custom-set-faces | |
'(my-tab-face ((((class color)) (:background "grey10"))) t) | |
'(my-trailing-space-face ((((class color)) (:background "gray10"))) t) | |
'(my-long-line-face ((((class color)) (:background "gray10"))) t)) | |
(add-hook 'font-lock-mode-hook | |
(function | |
(lambda () | |
(setq font-lock-keywords |