Skip to content

Commit 6e03b9f

Browse files
committed
treat weighted epsilons as non-epsilons
1 parent 6a219e3 commit 6e03b9f

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
22
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
33
project(lttoolbox
4-
VERSION 3.8.1
4+
VERSION 3.8.2
55
LANGUAGES CXX C
66
)
77
set(VERSION ${PROJECT_VERSION})

lttoolbox/transducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ Transducer::closure_all(const int epsilon_tag) const
256256
c.insert(i);
257257
auto range = transitions.at(i).equal_range(epsilon_tag);
258258
for (; range.first != range.second; range.first++) {
259+
if (range.first->second.second != default_weight) continue;
259260
c.insert(range.first->second.first);
260261
reversed[range.first->second.first].push_back(i);
261262
}
@@ -356,7 +357,7 @@ Transducer::determinize(int const epsilon_tag)
356357
{
357358
for(auto& it3 : transitions[it2])
358359
{
359-
if(it3.first != epsilon_tag)
360+
if(it3.first != epsilon_tag || it3.second.second != default_weight)
360361
{
361362
auto& it4 = all_closures[it3.second.first];
362363
mymap[std::make_pair(it3.first, it3.second.second)].insert(it4.begin(), it4.end());

tests/data/more-entry-weights.dix

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<dictionary>
3+
<alphabet>ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÄÅÆÇÈÉÊËÍÑÒÓÔÕÖØÙÚÜČĐŊŠŦŽabcdefghijklmnopqrstuvwxyzàáâäåæçèéêëíñòóôõöøùúüčđŋšŧž­-</alphabet>
4+
<sdefs>
5+
<sdef n="n"/>
6+
<sdef n="vblex"/>
7+
<sdef n="m"/>
8+
<sdef n="pr"/>
9+
<sdef n="def"/>
10+
<sdef n="inf"/>
11+
<sdef n="imp"/>
12+
<sdef n="pp"/>
13+
<sdef n="pprs"/>
14+
<sdef n="ger"/>
15+
<sdef n="subs"/>
16+
<sdef n="pres"/>
17+
<sdef n="past"/>
18+
<sdef n="p3"/>
19+
<sdef n="sg"/>
20+
<sdef n="pl"/>
21+
<sdef n="gen"/>
22+
</sdefs>
23+
<pardefs>
24+
<pardef n="liv/e__vblex">
25+
<e w="1"><p><l>e</l><r>e<s n="vblex"/><s n="inf"/></r></p></e>
26+
<e w="2"><p><l>e</l><r>e<s n="vblex"/><s n="imp"/></r></p></e>
27+
<e><p><l>ed</l><r>e<s n="vblex"/><s n="pp"/></r></p></e>
28+
<e w="1"><p><l>ing</l><r>e<s n="vblex"/><s n="pprs"/></r></p></e>
29+
<e w="3"><p><l>ing</l><r>e<s n="vblex"/><s n="ger"/></r></p></e>
30+
<e w="2"><p><l>ing</l><r>e<s n="vblex"/><s n="subs"/></r></p></e>
31+
<e><p><l>e</l><r>e<s n="vblex"/><s n="pres"/></r></p></e>
32+
<e><p><l>es</l><r>e<s n="vblex"/><s n="pres"/><s n="p3"/><s n="sg"/></r></p></e>
33+
<e><p><l>ed</l><r>e<s n="vblex"/><s n="past"/></r></p></e>
34+
</pardef>
35+
<pardef n="house__n">
36+
<e><p><l></l><r><s n="n"/><s n="sg"/></r></p></e>
37+
<e r="RL"><p><l>'s</l><r><s n="n"/><s n="sg"/><j/>'s<s n="gen"/></r></p></e>
38+
<e><p><l>s</l><r><s n="n"/><s n="pl"/></r></p></e>
39+
<e r="RL"><p><l>s'</l><r><s n="n"/><s n="pl"/><j/>'s<s n="gen"/></r></p></e>
40+
</pardef>
41+
</pardefs>
42+
<section id="main" type="standard">
43+
<e lm="house" w="1"><i>house</i><par n="house__n"/></e>
44+
<e lm="house" w="2"><i>hous</i><par n="liv/e__vblex"/></e>
45+
</section>
46+
</dictionary>

tests/lt_comp/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,9 @@ class RestrictRL2(RestrictTest):
113113
restrictflags = ['-v', 'oci']
114114
inputs = ['abc', 'ab']
115115
expectedOutputs = ['^abc/*abc$', '^ab/abbb<n><ind>$']
116+
117+
class ConflictingEntryWeights(ProcTest):
118+
procflags = ['-W']
119+
procdix = 'data/more-entry-weights.dix'
120+
inputs = ['house']
121+
expectedOutputs = ['^house/house<n><sg><W:1.000000>/house<vblex><pres><W:2.000000>/house<vblex><inf><W:3.000000>/house<vblex><imp><W:4.000000>$']

0 commit comments

Comments
 (0)