## Process this file with automake to produce Makefile.in ## Copyright (C) 2011 Samediggi ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . # Hfst fst variables: GT_SPELLER_SRC_HFST=generator-fstspeller-gt-norm.hfst GT_COMMON_SPELLER_HFST= ## Conditional string variables; # Set file name to the empty string or initial_letters_all depending on variable: tag_weighted_dep=$(shell \ if [[ $(ENABLE_CORPUS_WEIGHTS) == 'yes' ]] ; \ then \ echo "%-unit_weighted.hfst"; \ else \ echo "%-base.hfst"; \ fi) ####### Automake targets: ######## if WANT_SPELLERS if CAN_HFST GT_COMMON_SPELLER_HFST+=generator-desktopspeller-gt-norm.hfst GT_COMMON_SPELLER_HFST+=analyser-desktopspeller-gt-norm.hfst endif # CAN_HFST endif # WANT_SPELLERS noinst_DATA=$(GT_COMMON_SPELLER_HFST) #### 1. Copy base fst from parent dir: generator-desktopspeller-gt-norm-base.hfst: ../generator-fstspeller-gt-norm.hfst $(AM_V_FST2FST)$(HFST_FST2FST) --format=openfst-tropical -i $< -o $@ #### 2. Add corpus-based frequency weights (all non-hits will disappear from #### the fst): %-freq_weighted.hfst: \ %-base.hfst \ $(SURFWEIGHTS) $(AM_V_COMPOSE)$(HFST_COMPOSE) $(HFST_FLAGS) -F \ $< $(SURFWEIGHTS) \ -o $@ #### 3. Add a default unit weight to anything not covered by the corpus #### by combining (unioning) the unitweighted.hfst (which is the full #### lexical fst) with the frequency/corpus-based fst - use priority #### union to avoid duplication of paths and thus make a mutch smaller #### (and hence faster) fst: %-unit_weighted.hfst: %-freq_weighted.hfst \ unitweighted.hfst $(AM_V_HXFST)$(PRINTF) "\ set encode-weights ON \n\ read regex \ @\"$<\" \ | @\"unitweighted.hfst\" \ ; \n\ save stack $@\n\ quit\n" | $(HFST_XFST) -p $(MORE_VERBOSITY) #### 4. Add tag-based weights, for adjusting weights according to morphology #### and other tag-based penalties like words that should not be suggested: %-tag_weighted.hfst: $(tag_weighted_dep) \ $(srcdir)/weighting/$(TAGWEIGHTS) $(AM_V_REWEIGHT)$(HFST_REWEIGHT) $(MORE_VERBOSITY) $(HFST_FLAGS) \ -T $(srcdir)/weighting/$(TAGWEIGHTS) --arcs-only -i $< \ -o $@ #### 5. Finally, remove the surface word boundary symbol and do other #### general cleanup: generator-desktopspeller-gt-norm.tmp.hfst: \ generator-desktopspeller-gt-norm-tag_weighted.hfst \ filters/remove-word-boundary.hfst \ filters/remove-usage-tags.hfst $(AM_V_HXFST)$(PRINTF) "\ set encode-weights ON \n\ read regex \ @\"filters/remove-usage-tags.hfst\" \ .o. @\"$<\" \ .o. @\"filters/remove-word-boundary.hfst\" \ ; \n\ save stack $@\n\ quit\n" | $(HFST_XFST) -p $(MORE_VERBOSITY) # Copy the tmp transducer to the final one. This allows local overrides. %.hfst: %.tmp.hfst $(AM_V_CP)cp -f $< $@ # Invert the final fst, to enable symmetric yaml tests and easy manual testing: analyser-%.hfst: generator-%.hfst $(AM_V_INVERT)$(HFST_INVERT) $(MORE_VERBOSITY) $(HFST_FLAGS) -i $< -o $@ ####### Other targets: ########### clean-local: -rm -f *.hfst *.txt include $(top_srcdir)/am-shared/tools-spellcheckers-fstbased-desktop_weights-dir-include.am include $(top_srcdir)/am-shared/silent_build-include.am