Skip to content

Commit

Permalink
Merge pull request #614 from latin-language-toolkit/search_index_fix
Browse files Browse the repository at this point in the history
Search index fix
  • Loading branch information
balmas committed Feb 2, 2015
2 parents 530dec8 + 4693b26 commit b7a121e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
16 changes: 13 additions & 3 deletions app/js/arethusa.morph/morph.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ angular.module('arethusa.morph').service('morph', [
mergeDuplicateForms(forms[0], res);
var newForms = makeUnique(res);
arethusaUtil.pushAll(forms, newForms);

if (self.preselect) {
preselectForm(forms[0], id);
}
Expand Down Expand Up @@ -612,8 +611,18 @@ angular.module('arethusa.morph').service('morph', [
};

var searchIndex;
function createSearchIndex() {
function initSearchIndex() {
// @balmas: I don't know if there is any reason not to just
// initialize it where it's declared. This was split from
// createSearchIndex for
//https://github.com/latin-language-toolkit/arethusa/issues/613
searchIndex = {};
}
function loadSearchIndex() {
// we should have initialized it before here but just in case
if (! angular.isDefined(searchIndex)) {
initSearchIndex();
}
angular.forEach(state.tokens, function(token, id) {
var form = token.morphology || {};
addToIndex(form, id);
Expand Down Expand Up @@ -719,8 +728,9 @@ angular.module('arethusa.morph').service('morph', [
configure();
self.emptyPostag = createEmptyPostag();
self.analyses = seedAnalyses();
initSearchIndex();
loadInitalAnalyses();
createSearchIndex();
loadSearchIndex();
plugins.declareReady(self);
};
}
Expand Down
40 changes: 20 additions & 20 deletions dist/examples/clean.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@
<word id="44" form="dare" lemma="" postag="" relation="" head=""/>
<word id="45" form="adduceretur" lemma="" postag="" relation="AuxK" head="0"/>
</sentence>
<sentence id="1" document_id="Caes. BG. 2.1" subdoc="" span="">
<word id="45" form="Coniurandi" lemma="" postag="" relation="" head=""/>
<word id="46" form="has" lemma="" postag="" relation="" head=""/>
<word id="47" form="esse" lemma="" postag="" relation="" head=""/>
<word id="48" form="causas" lemma="" postag="" relation="" head=""/>
<word id="49" form="primum" lemma="" postag="" relation="" head=""/>
<word id="50" form="quod" lemma="" postag="" relation="" head=""/>
<word id="51" form="vererentur" lemma="" postag="" relation="" head=""/>
<word id="52" form="ne" lemma="" postag="" relation="" head=""/>
<word id="53" form="," lemma="punc1" postag="u--------" relation="AuxX" head=""/>
<word id="54" form="omni" lemma="" postag="" relation="" head=""/>
<word id="55" form="pacata" lemma="" postag="" relation="" head=""/>
<word id="56" form="Gallia" lemma="" postag="" relation="" head=""/>
<word id="57" form="," lemma="punc1" postag="u--------" relation="AuxX" head=""/>
<word id="58" form="ad" lemma="" postag="" relation="" head=""/>
<word id="59" form="eos" lemma="" postag="" relation="" head=""/>
<word id="60" form="exercitus" lemma="" postag="" relation="" head=""/>
<word id="61" form="noster" lemma="" postag="" relation="" head=""/>
<word id="62" form="adduceretur" lemma="" postag="" relation="" head=""/>
<word id="63" form="." lemma="punc1" postag="u--------" relation="AuxK" head="0"/>
<sentence id="2" document_id="Caes. BG. 2.1" subdoc="" span="">
<word id="1" form="Coniurandi" lemma="" postag="" relation="" head=""/>
<word id="2" form="has" lemma="" postag="" relation="" head=""/>
<word id="3" form="esse" lemma="" postag="" relation="" head=""/>
<word id="4" form="causas" lemma="" postag="" relation="" head=""/>
<word id="5" form="primum" lemma="" postag="" relation="" head=""/>
<word id="6" form="quod" lemma="" postag="" relation="" head=""/>
<word id="7" form="vererentur" lemma="" postag="" relation="" head=""/>
<word id="8" form="ne" lemma="" postag="" relation="" head=""/>
<word id="9" form="," lemma="punc1" postag="u--------" relation="AuxX" head=""/>
<word id="10" form="omni" lemma="" postag="" relation="" head=""/>
<word id="11" form="pacata" lemma="" postag="" relation="" head=""/>
<word id="12" form="Gallia" lemma="" postag="" relation="" head=""/>
<word id="13" form="," lemma="punc1" postag="u--------" relation="AuxX" head=""/>
<word id="14" form="ad" lemma="" postag="" relation="" head=""/>
<word id="15" form="eos" lemma="" postag="" relation="" head=""/>
<word id="16" form="exercitus" lemma="" postag="" relation="" head=""/>
<word id="17" form="noster" lemma="" postag="" relation="" head=""/>
<word id="18" form="adduceretur" lemma="" postag="" relation="" head=""/>
<word id="19" form="." lemma="punc1" postag="u--------" relation="AuxK" head="0"/>
</sentence>
</treebank>

0 comments on commit b7a121e

Please sign in to comment.